search for: fhat

Displaying 20 results from an estimated 22 matches for "fhat".

Did you mean: chat
2010 May 04
3
Kernel density estimate plot for 3-dimensional data
Hi! I have a problem with Kernel density estimate plot for 3-dimensional data in ks-package. Here the example: # load ks, spatstat # three-dimensional kernel density of B B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1))) x <- unclass(B$data)$df H <- Hpi(x) fhat <- kde(x, H=H) plot(fhat) plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z')) If I try to insert my own coordinates instead of the artificial 3D-pattern, it does not work. It would be great, if anybody could help me! Thanks Pascal [[alternati...
2011 Sep 09
2
How to translate the 2D-density matrix (the output of bkde2D function) into matrix of datapoints' amounts?
...hat function bkde2D (package "KernSmooth") returns a matrix of density estimates over the mesh induced by x1 and x2. In Details it is written that "... heights of the kernel, scaled by the bandwidths, at each datapoint are summed. This sum, after a normalization, is the corresponding fhat value in the output". There are several questions: 1) How to calculate amount (sum) of datapoints from this fhat value? Is it a non-normalized matrix of fhat values? 2) Values in fhat matrix are greater than 1 sometimes, why? Values of density are normalized and hence must be less than 1, isn...
2011 Dec 22
1
overlaid filled contour plots
...quot;) con <- url("http://euclid.psych.yorku.ca/SCS/Private/Test/bkde2D-boot.RData") ## print the value to see what objects were saved. print(load(con)) close(con) col <- c("black", rainbow(5, start=.6, end=.1)) clr <- col[c(1,3,6)] contour(dest0$x1, dest0$x2, dest0$fhat, nlevels=4, xlim=c(-8,4), ylim=c(-3,0), cex.lab=1.25, xlab="GNP", ylab="Unemployed" ) contour(dest1$x1, dest1$x2, dest1$fhat, nlevels=4, add=TRUE, col=clr[2]) contour(dest2$x1, dest2$x2, dest2$fhat, nlevels=4, add=TRUE, col=clr[3]) lines(rbind(cm0, cm1, cm2)) point...
2009 Nov 26
2
Export kde object as shapefile
I am trying to estimate home range size using the plug-in method with kernel density estimation in the kernel smoothing (ks) package. Unless there is another way I am not familiar with, in order to calculate spatial area under the space I need to convert my kde () object into a spatial object somehow in order to calculate its spatial area. Could someone demonstrate how this might be done? --
2004 Nov 03
1
Kernel Density estimation - locfit package
...I am presently using the locfit package in "R" and would appreciate some help here. Could anyone tell me tell me how I can obtain the various components (x and y values)of the density estimation after using the "R" command "locfit"? For example, with the command "fhat<-density(somename)" I can obtain the x and y values by simply calling "fhat$x" and "fhat$y". This doesn't seems to work with the "locfit" command. Thank you in advance. Regards, Kwabena -------------------------------------------- Kwabena Adusei-Poku U...
2013 Sep 22
2
colores
Como usas la función image puedes consultar la ayuda ?image o help(image) y encontrarás el siguiente ejemplo donde se usa un diferente color Palette (mencionada por pepeceb en su respuesta). x <- 10*(1:nrow(volcano)) y <- 10*(1:ncol(volcano)) image(x, y, volcano, col = terrain.colors(100), axes = FALSE) # O puedes usar directamente el número para indicar el color image(x, y, volcano, col =
2002 Mar 31
1
How to get the datapoints of an density estimationwithlocfit?
...0.02 5 .... Thank you for your help and your time Ralf > As far as I know, locfit does not store its estimates. You have to use > the fitted.values() function. So, something like: > > library(locfit) > x <- rnorm(200) > f <- locfit( ~ x) > fhat <- fitted.values(f) > cbind(x, fhat) > > I think that will give you what you want. > > -roger > _______________________________ > UCLA Department of Statistics > rpeng at stat.ucla.edu > http://www.stat.ucla.edu/~rpeng > > On Fri, 29 Mar 2002, Ralf.Kloessinger...
2006 Mar 31
1
mutual information for two time series
...datin[,2]) rhemb<-embed(rh,lmax) lhc<-lh[1:length(rhemb[,1])] for (i in 1:lmax) { rhc<-rhemb[,i] kd<-bkde2D(cbind(lhc,rhc),bandwidth=c(dpik(lhc),dpik(rhc)),gridsize=c(100,10 0),truncate=T) #2d kernel density estimate in 2 dimensions) kdmat<-as.matrix(kd$fhat) for (j in 1:100){ p<-sum(kdmat[j,]) lhplogp[j]<-p*log(p) } lhplogp[is.nan(lhplogp)]<-0 hlh<- -1*sum(lhplogp) #entropy of left hemsisphere for (j in 1:100){ p...
2013 Sep 22
0
colores
...;red") library("KernSmooth") cps_bkde <- bkde2D(cbind(cps$experience, log(cps$wage)), bandwidth = c(3.5, 0.5), gridsize = c(200, 200)) #con este plot de densidad se expresa mejor la idea a expresar image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat, col = rev(gray.colors(10, gamma = 1)), ############################AQUI PARA CAMBIAR Y PONER TONOS ROJIZOS MAS FUERTES xlab = "experience", ylab = "log(wage)") box() lines(fit ~ experience, data = cps2) lines(lwr ~ experience, data = cps2, lty = 2) lin...
2009 Dec 14
0
Confused on using expand.grid(), array(), image() and npudens(np) in my case
...;- sort(unique(d$tf)) #length is 3 x.seq <- seq(0,1,0.02) #length is 51 y.seq <- seq(0,1,0.02) #length is 51 #Confusion2:what is the correct sequence for the three variables (year.seq,x.seq and y.seq) in expand.grid() data.eval <- expand.grid(tf=year.seq,x=x.seq,y=y.seq) #confusion2 fhat <- fitted(npudens(bws=bw, newdata=data.eval)) #Confusion3:what is the correct sequence for the three variables in the c() options of array() f <- array(fhat, c(51,51,3)) #number of year.seq is 3, and number of x.seq and y.seq are 51,confusion3 brks <- quantile(f, seq(0,1,0.05));cols &l...
2011 Sep 30
1
Implementing Silverman's Negative Reflection
...verman (1986) on p.31, ie I have a non-negative dataset and would like to estimate the density by applying a reflection method where the reflected points have weight -1. I thought there should be a way to evaluate the wanted kernel at the required points, in other words to calculate formula (2.16): fhat(x) = 1/(nh) * sum_{i=1}^{n}{ K( (x-Xi) /h) - K( (x-Xi) /h) } Unfortunately, I am still not that good and skilled with R - does anybody know how to do this- Or maybe a hint...? Thank you!! PS: you can also find the mentioned passage on p.21 of http://ned.ipac.caltech.edu/level5/March02/Silverman/p...
2002 Mar 29
2
How to get the datapoints of an density estimation with locfit?
Hello!!! I'm just a beginner of R. I work with locfit to get the density from an numeric vector. It looks good when I plot the graph, but I need the output data of locfit. For example I need somthing like that (only integer values for the input): numeric vector (input of locfit) density (output of locfit) 1 0.05.... 2 0.04.. 3 0.01 ... Thank you for your help and your time.
2012 Jul 26
2
density
Hi all, I have a question regarding the density function which gives the kernel density estimator. I want to decide the bandwidth when using gaussian kernel, given a set of observations. I am not familiar with different methods for bandwidth determination. Below are the different ways in R on deciding the bandwidth. Can anyone give an idea on which ones are preferred. Also, how can I take
2010 Apr 19
1
densCols: what are the computed densities and how to create a legend
Hi, I'm using the densCols function for a scatterplot and cannot figure out 1) how to extract the computed densities, and 2) how to create a legend based that represents the upper and lower ranges of the densities. For example: movers.den <- densCols(move$x, move$y) table(movers.den) #08306B #083775 #083B7C #083D7E #3989C1 #3F8FC4 28 22 101 25
2007 Sep 07
1
contourplot lines, text, and mtext
...) and I want to add straight lines to it, how do I do this? I see that there are llines() and lsegement() functions for lattice plots, but they don't seem to do anything in this case: library(lattice) library(KernSmooth) x=rnorm(10000) y=x+rnorm(x,0,.5) a=bkde2D(cbind(x,y),.7) z=as.vector(a$fhat) grid=expand.grid(x=a$x1,y=a$x2) grid$z=z contourplot(z~x*y,data=grid,region=T,col.regions=gray(seq(1,0,len=255)),colorkey=T,cuts=50,contour=F) llines(x=c(-5,5),y=c(-5,5)) > NULL lsegments(x0=-5,y0=-5,x1=5,y1=5) I'm just trying to do the equivalent of abline(0,1) on the plot. ltext(), on...
2006 Jul 04
1
problem getting R 2.3.1 svn r38481 to pass make check-all
...is agrees with the > ## large-sample approximation to the Kolmogorov-Smirnov statistic. > ## > > > superror <- function(rfoo,pfoo,sample.size,...) { + x <- rfoo(sample.size,...) + tx <- table(x) + xi <- as.numeric(names(tx)) + f <- pfoo(xi,...) + fhat <- cumsum(tx)/sample.size + max(abs(fhat-f)) + } > > pdkwbound <- function(n,t) 2*exp(-2*n*t*t) > > qdkwbound <- function(n,p) sqrt(log(p/2)/(-2*n)) > > dkwtest <- function(stub = "norm", ..., + sample.size = 10000, pthreshold = 0.0...
2002 Apr 03
0
Another question on locfit
...ec, nrow = 101, ncol = 1) and I tried to change the ev parameter: > fit <- locfit(~imposter, kern="gauss", renorm=T, xlim=c(1e-20,100), ev=vec) This works good but when I tried to get the density points I get an error, this happens also when I use the matrix (mat) for ev: > fhat <- fitted(fit) Error in fitted.locfit(fit) : NA/NaN/Inf in foreign function call (arg 10) I think arg 10 means "dp" and there I got the following parameters: > fit$dp nnalph fixh adpen cut lk df1 df2 rv 0.7 0.0 0.0 0.8 0.0 0.0 0.0 1....
2013 Sep 22
2
colores
¿ como se pueden cambiar estos colores, gray.colors a otros library("KernSmooth") cps_bkde <- bkde2D(cbind(cps$experience, log(cps$wage)), bandwidth = c(3.5, 0.5), gridsize = c(200, 200)) image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat, col = rev(gray.colors(10, gamma = 1)), #### pregunta?como se pueden cambiar estos colores xlab = "experience", ylab = "log(wage)") box() lines(fit ~ experience, data = cps2) lines(lwr ~ experience, data = cps2, lty = 2) -- Este mensaje le ha llega...
2008 Dec 08
1
DLM - Covariates in the system equation
Is there a way to add covariates to the system equation in a time-varying approach: Y[t] = F'[t]theta[t] + v[t], v[t] ~ N[0,V] #observation equation theta[t] = theta[t-1] + psi*Z[t] + w[t], w[t] ~ N[0,W] #system equation While F[t] is a matrix of regressors to capture the short term effect on the response series Y, Z[t] measures the long-term effect of either (1) two policies by a step
2000 Mar 22
4
density ellipses?
Hello, has anybody written a function to plot density ellipses (95%, 99% or anything) in a scatterplot? I found nothing in any package, nor in the list archives. There does seem to be a contributed package "ellipse" for S-Plus (on S-Archive), but it does a lot more than what I would need. Still, if anybody ported it to R, I'd be grateful for a link. I'm a bit afraid to try the