search for: xfit

Displaying 17 results from an estimated 17 matches for "xfit".

Did you mean: fit
2010 Nov 10
1
par mfrow in "function" problem
Hi all, I defined the following ############################# myhist=function(x){ hist(x,xlab="",main="") h=hist(x) xfit=seq(min(x),max(x),length=100) yfit=dnorm(xfit,mean(x),sd=sd(x)) yfit=yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2) } ############################# individually, it worked fine however, if I used par(mfrow=c(2,2)) each time i run myhist it produces TWO plots...
2009 Sep 02
2
Howto fit normal curve into histogram using GGPLOT2
Currently, I am doing it this way. x <- mtcars$mpg h<-hist(x, breaks=10, col="red", xlab="Miles Per Gallon", main="Histogram with Normal Curve") xfit<-seq(min(x),max(x),length=40) yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) yfit <- yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2) But since, ggplot2 has more appealing graphics, I wonder how can it be done. -G.V.
2005 Oct 14
1
lattice with predicted values
...mod ~ lm(Y ~ COV + FACT) #The following draws the right predictions if the relation is the same for all factor levels, but I can't figure out how to have the same slopes but different intercepts. # Function to draw predictions in xyplot panel.predfinal <- function(mod, x, y) { xfit <- seq(min(x), max(x), length=21) yfit <- predict(mod, newdata=data.frame(COV=xfit)) llines(xfit,yfit,lty=1) } xyplot(Y ~ COV | FACT, panel=function(x,y,groups,subscripts){ panel.xyplot(x,y) panel.predfinal(mod,x,y) } I would be very grateful...
2010 Feb 19
1
"Legend" question
...several ways but ended up with getting mixed line and point types.My code is as following: hist(CDR3,xlab="",ylab="",main=NULL, xlim=c(min(CDR3),max(CDR3)),freq=FALSE,col="lightgrey") # draw the overlaying normal curve and kernel curve, draw mean and median on X-axis xfit<-seq(min(CDR3),max(CDR3),length=100) yfit<-dnorm(xfit,mean=mean(CDR3),sd=sd(CDR3)) lines(xfit, yfit, col="red",lty=1,lwd=1) lines(density(CDR3,from=min(CDR3),to=max(CDR3)),col="blue",lty=1,lwd=1) mean(CDR3) median(CDR3) points(x=mean(CDR3),y=0,pch=19,col="red",c...
2004 Aug 24
0
additional examples for R-intro.texi (PR#7195)
...3 + +$hessian + [,1] [,2] +[1,] 11.94725 -7661.319 +[2,] -7661.31875 8039421.153 + +$code +[1] 3 + +$iterations +[1] 26 +@end example + + To obtain the approximate standard errors (SE) of the estimates we do: @example @@ -5032,7 +5057,7 @@ @example > plot(x, y) > xfit <- seq(.02, 1.1, .05) -> yfit <- 212.68384222 * xfit/(0.06412146 + xfit) +> yfit <- out$estimate[1] * xfit/(out$estimate[2] + xfit) > lines(spline(xfit, yfit)) @end example --- R-intro.texi~ Tue Aug 24 11:21:38 2004 +++ R-intro.texi Tue Aug 24 11:21:38 2004 @@ -3307,8 +3307,8...
1999 Dec 09
1
nlm() problem or MLE problem?
...h I attach. fitweibull<-function() { rt<-scan("r/rt/data2/triam1.dat") rt<-sort(rt) plot(rt,ppoints(rt)) a<-9 b<-.27 fn<-function(p) -sum( log(dweibull(rt,p[1],p[2])) ) cat("starting -log like=",fn(c(a,b)),"\n") out<-nlm(fn,p=c(a,b), hessian=TRUE) xfit<-seq(min(rt),max(rt),(max(rt)-min(rt))/100) yfit<-pweibull(xfit,out$estimate[1], out$estimate[2]) lines(xfit,yfit,lty=2) yfit2<-pweibull(xfit,a, b) lines(xfit,yfit2) list(out=out) } I got the starting values a=9, b=.27 from fitting the Weibull CDF by eye to a quantile plot of the data. Th...
2009 Oct 25
1
lsfit residuals
I'm trying to extract the points above and below a particular lsfit. I can only get the residuals from the original fit though. x = runif(100, 0, 10) plot(x) abline(lsfit(1:100, test)) abline(lsfit(1:100, test + sd(test))) #I want the points above THIS line. Is there a way to use the coefficients from the fit to do this? Thanks for any help.
2001 Oct 13
2
hist and normal curve
Dear R people: I would like to superimpose a normal curve on a histogram. I've seen this example in a book, somewhere. I know that you draw the hist, get the mean and sd of the data set, but then I'm stuck. Could you help, please? Thanks! Erin hodgess at uhddx01.dt.uh.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read
2005 Sep 25
4
hist(x, ...) with normal distribution curve
. I am looking for a histogram or box plot with the adding normal distribution curve I think that must be possible, but I am not able to find out how to do. Regards Knut
2000 Nov 09
2
simple mixture
Dear All, I am trying to do some simple mixture analyses. For instance, I have a sample of n observations and I suspect they come from two different exponential distributions with parameters rate1 and rate2, respectively. So, I want to estimate rate1, rate2, and the proportions of both kinds of individuals in the sample. I had a look at the packages mda and mclust, but they do not seem to do this
2007 Jun 07
2
Nonlinear Regression
Hello I followed the example in page 59, chapter 11 of the 'Introduction to R' manual. I entered my own x,y data. I used the least squares. My function has 5 parameters: p[1], p[2], p[3], p[4], p[5]. I plotted the x-y data. Then I used lines(spline(xfit,yfit)) to overlay best curves on the data while changing the parameters. My question is how do I calculate the residual sum of squares. In the example they have the following: df <- data.frame( x=x, y=y) fit <- nls(y ~SSmicmen(s, Vm, K), df) fit In the second line how would I input my fu...
2002 Dec 09
1
heteroscedasticity analysis
Hello, First, sorry for my poor english, I will try to be understood. It's the first time I try this "r-help mailing list" and I hope it will be a success. I am working on heteroscedasticity analysis. I would like to get the "Box-Ljung" and the "Lagrange multipliers" test. I found the first one in the library "ts", but I can't find the second one.
2012 Jan 02
1
sm.density.compare - a lot of curves
Dear all, Let say I have a sets of numbers: rno1 = rnorm(1000) rno2 = rnorm(1000) If I write request as follow: sm.density.compare (rno, rno3, xfit=min(rno), max(rno2)) why I receive a lot of curves in my plot, while I have only two data sets? regards Przemek -- View this message in context: http://r.789695.n4.nabble.com/sm-density-compare-a-lot-of-curves-tp4253039p4253039.html Sent from the R help mailing list archive at Nabble.com.
2013 Jun 19
1
nls singular gradient ..as always..
...evious posts but couldn't find a solution. I use the following code to fit an exponential model to my data. I have 4 different datasets. For 3 datasets nls seems to work fine and I have no error messages. But for 1 dataset I am getting the "world known" singular gradient error. xfit.dNEE <- nls(vario.dNEE~V*(1-exp(-1*dist/L)),data=ndat,start=list(V=vstart,L=lstart),trace=T) I tried also with different starting values but still the same error... Any help would be highly welcome. Thank you in advance. -- View this message in context: http://r.789695.n4.nabble.com/nl...
2005 Oct 14
2
Help with lattice, regressions and respective lines
# Dear R list, # # I'm needing help with lattice, regression and respective lines. # My data is below: bra = gl(2, 24, label = c('c', 's')) em = rep(gl(3, 8, label = c('po', 'pov', 'ce')), 2) tem = rep(c(0, 0, 30, 30, 60, 60, 90, 90), 6) tem2 = tem^2 r = rep(1:2, 24) y = c(40.58, 44.85, 32.55, 35.68, 64.86, 51.95, 42.52, 52.21,
2005 Aug 12
6
evaluating string variables
Hello!!! I have a folder (C:/R/) with matrix files, named by number, i.e. 0.mat, 1.mat,...,1250.mat. In this case, they are 5x5 simetric matrices. I would like to compute a property for each matrix and put calculated values into a data frame for posterior ploting and printing. Below there is an example for 7 matrices (0.mat..6.mat) #define data frame L <- data.frame(frame=numeric(7),
2001 Aug 12
2
rpart 3.1.0 bug?
I just updated rpart to the latest version (3.1.0). There are a number of changes between this and previous versions, and some of the code I've been using with earlier versions (e.g. 3.0.2) no longer work. Here is a simple illustration of a problem I'm having with xpred.rpart. iris.test.rpart<-rpart(iris$Species~., data=iris[,1:4], parms=list(prior=c(0.5,0.25, 0.25))) + ) >