search for: myfit

Displaying 20 results from an estimated 37 matches for "myfit".

2017 Jun 18
0
R_using non linear regression with constraints
...values of parameters a and b of > function myfun which give the best fit for the data set, mydata. > > mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) > > myfun=function(a,b,r,t){ > prd=a*b*(1-exp(-b*r*t)) > return(prd)} > > and using nlsLM > > myfit=nlsLM(y~myfun(a,b,r=2,t=x),data=mydata,start=list(a=2000,b=0.05), > lower = c(1000,0), upper = c(3000,1)) > > It works. But now I would like to introduce a constraint which is a*b<1000. At the moment your coefficients do satisfy that constraint so that dataset is not...
2017 Jun 18
2
R_using non linear regression with constraints
I am using nlsLM {minpack.lm} to find the values of parameters a and b of function myfun which give the best fit for the data set, mydata. mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) myfun=function(a,b,r,t){ prd=a*b*(1-exp(-b*r*t)) return(prd)} and using nlsLM myfit=nlsLM(y~myfun(a,b,r=2,t=x),data=mydata,start=list(a=2000,b=0.05), lower = c(1000,0), upper = c(3000,1)) It works. But now I would like to introduce a constraint which is a*b<1000. I had a look at the option available in nlsLM to set constraint via nls.lm.control. But it's...
2017 Jun 18
3
R_using non linear regression with constraints
...; function myfun which give the best fit for the data set, mydata. >> >> mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) >> >> myfun=function(a,b,r,t){ >> prd=a*b*(1-exp(-b*r*t)) >> return(prd)} >> >> and using nlsLM >> >> myfit=nlsLM(y~myfun(a,b,r=2,t=x),data=mydata,start=list(a=2000,b=0.05), >> lower = c(1000,0), upper = c(3000,1)) >> >> It works. But now I would like to introduce a constraint which is a*b<1000. > > At the moment your coefficients do satisfy that constraint so...
2017 Jun 18
0
R_using non linear regression with constraints
...ivative if it can, else squawks. JN # Here's the script # # # Manoranjan Muthusamy <ranjanmano167 at gmail.com> # library(minpack.lm) mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) myfun=function(a,b,r,t){ prd=a*b*(1-exp(-b*r*t)) return(prd)} # and using nlsLM myfit=nlsLM(y~myfun(a,b,r=2,t=x),data=mydata,start=list(a=2000,b=0.05), lower = c(1000,0), upper = c(3000,1)) summary(myfit) library(nlsr) r <- 2 myfitj=nlxb(y~a*b*(1-exp(-b*r*x)),data=mydata,start=list(a=2000,b=0.05), trace=TRUE) summary(myfitj) print(myfitj) myfitj2<-nlxb(y~ab...
2020 Oct 17
2
??? is to nls() as abline() is to lm() ?
...x <- c(rnorm(5000, 3, 5), rnorm(2000, -5, 7)) # Two normal distributions ... # Histogram h <- hist(x, freq = FALSE, breaks = seq(min(x)-2, max(x)+2, by = 1), col = "#cfd7fa", main = "", ylab = "density", xlab = "x") # Fit myFit <- fitNorm(h$mids, h$density) # Now: what I can do is, patch together the model function ... mF <- function(x, a = coef(myFit)["a"], mu = coef(myFit)["mu"], sig = coef(myFit)["sig"]){ a / (sig*sqrt(2*pi)) * ex...
2017 Jun 18
3
R_using non linear regression with constraints
...jdtass <- aggregate( ( objdta$myfun - objdta$y )^2 , objdta[ , c( "a", "b" ) ] , FUN = function( x ) sum( x, na.rm=TRUE ) ) objdtassmin <- objdtass[ which.min( objdtass$x ), ] myfit <- nlsLM( y ~ myfun( a, b, r=2, t=x ) , data = mydata , start = list( a = 2000 , b = 0.05 ) , lower = c( 1000, 0 ) , upper = c( 3000, 1 ) ) a <- as.vector( coef...
2012 Aug 25
2
Standard deviation from MANOVA??
Hi, I have problem getting the standard deviation from the manova output. I have used the manova function: myfit <- manova(cbind(y1, y2) ~ x1 + x2 + x3, data=mydata) . I tried to get the predicted values and their standard deviation by using: predict(myfit, type="response", se.fit=TRUE) But the problem is that I don't get the standard deviation values, I only get the predicted value...
2017 Jun 18
0
R_using non linear regression with constraints
...fun - objdta$y )^2 > , objdta[ , c( "a", "b" ) ] > , FUN = function( x ) > sum( x, na.rm=TRUE ) > ) > objdtassmin <- objdtass[ which.min( objdtass$x ), ] > > myfit <- nlsLM( y ~ myfun( a, b, r=2, t=x ) > , data = mydata > , start = list( a = 2000 > , b = 0.05 > ) > , lower = c( 1000, 0 ) > , upper = c( 3000, 1 ) >...
2020 Oct 17
0
??? is to nls() as abline() is to lm() ?
...5, 7)) # Two normal distributions ... > > # Histogram > h <- hist(x, freq = FALSE, > breaks = seq(min(x)-2, max(x)+2, by = 1), > col = "#cfd7fa", > main = "", ylab = "density", xlab = "x") > # Fit > myFit <- fitNorm(h$mids, h$density) > > # Now: what I can do is, patch together the model function ... > mF <- function(x, > a = coef(myFit)["a"], > mu = coef(myFit)["mu"], > sig = coef(myFit)["sig&quo...
2008 Feb 24
1
what missed ----- CART
Hi all, Can anyone who is familar with CART tell me what I missed in my tree code? library (MASS) myfit <- tree (y ~ x1 + x2 + x3 + x4 ) # tree.screens () # useless plot(myfit); text (myfit, all= TRUE, cex=0.5, pretty=0) # tile.tree (myfit, fgl$type) # useless # close.screen (all= TRUE) # useless My current tree plot resulted from above code shows as: 1. overlapped #s cau...
2011 Jan 25
1
Predictions with 'missing' variables
Dear List, I think I'm going crazy here...can anyone explain why do I get the same predictions in train and test data sets below when the second has a missing input? y <- rnorm(1000) x1 <- rnorm(1000) x2 <- rnorm(1000) train <- data.frame(y,x1,x2) test <- data.frame(x1) myfit <- glm(y ~ x1 + x2, data=train) summary(myfit) all(predict(myfit, test) == predict(myfit, train)) [1] TRUE Thanks, Axel. [[alternative HTML version deleted]]
2003 Oct 23
3
List of lm objects
...on this e-mail list: for (y in df[, 3:5]) { mod = lm(y ~ Trt*Dose, data = x, contrasts = list(Trt = contr.sum, Dose = contr.sum)) Anova(mod, type = "III") } ## by John Fox or for (myname in names(myframe)){ mycall <- substitute(lm(myvar~etc.etc.....),list(myvar=as.name(myname))) myfit <- eval(mycall) print(summary(myfit)) } ## by Peter Dalgaard But instead of printing summary or Anova results, I need to generate a list containing all the lm() objects. Is that possible? How? Thanks, Gabriela.
2007 Jan 21
1
for loop problem
...A beginners question which I could not find the answer to in earler posts. My thought process: Here "z" is a 119 x 15 data matrix Step 1: start at column one, bind every column with column 1 Step2: use the new matrix, "test", in the fitCopula package Step3: store each result in myfit, bind each result to "answer" Step4: return "answer" copula_est <- function(z) { for(i in 1:length(z[1,])) { my.cop <- normalCopula(param = 0.5, dim = 2) test <- cbind(z[,1],z[,i]) myfit[i] <- fitCopula(test,my.cop, start=0.3) } answer <- cbind(myfit[i...
2006 Mar 05
1
duration analysis
Hi, I am trying to estimate the effects of covariates on the hazard function, rather than on the survival. I know this is actually the same thing. For example, using the survival package, and doing: > myfit <- survreg( Surv(time, event) ~ mymodel ) all I have to do to get the quantities of my interest is > -myfit$coefficients/myfit$scale The standard erros are easily worked out, as the absolute z-statistics are the same. Ok, so I can get easily what I want from survreg(). But I'd like to...
2010 Sep 19
2
working with eval and environments
...y ~ 1 + x1 + x2") cat("in fit",NROW(train),"\n") model <- do.call(trial at fit$func,trial at fit$args) print(model$call) select <- do.call(trial at step$func,trial at step$args) } mydf <- data.frame(y <- runif(100),x1 <- runif(100),x2 <- runif(100)) myfit <- list(func="wrap.lm",args=alist(formula=null,data=train)) mystep <- list(func="wrap.step",args=alist(object=model,scope=full,trace=0)) setClass("trial",representation(n="numeric",fit="list",step="list")) trial1 <- new("tri...
2005 Jun 09
1
getting more than the coefficients
Hi there, I am trying to export a regression output to Latex. I am using the xtable function in the xtable library. Doing myfit <- lm(myformula, mydata) print.xtable(xtable(myfit), file="myfile") only returns the estimated coefficients and the correspondent standard erros, t-statiscs and p-values. But I wish to get a bit more, say, the number of observations used in the regresion, the R^2 and F statistics. A...
2010 Jan 27
1
control of scat1d tick color in plot.Predict?
...l isn't clear to me how to do this in the context of lattice. Guidance would be greatly appreciated. Thanks, Mike Babyak Duke University Medical Center My code using R 2.10.1/windows XP myx<-c(1,2,3,4) myy<-c(1,2,3,5) library(rms) d<-datadist(myx) options(datadist="d") myfit<-ols(myy~myx,x=T,y=T) p1<-Predict(myfit,myx =.) library(lattice) #change line to black line <- trellis.par.get("plot.line") line$col <- 1 trellis.par.set("plot.line", line) plot(p1, data=llist(myx),col.fill="lightgray", lwd=1.5) [[alternative HTML ver...
2003 Nov 25
1
problem plotting curve through data
...ough a set of data. I have created a dataframe (df) of Stimulus Intensities (xstim) and Normalized Responses (yresp), and I've used nls() to calculate a nonlinear regression, like so: -------------------- > f <- yresp ~ xstim^n / (xstim^n + B^n) > starts <- list(n=.6, B=11) > myfit <- nls(formula=f, data=df, start = starts) >myfit Nonlinear regression model model: yresp ~ xstim^n/(xstim^n + B^n) data: df n B 0.8476233 5.7943791 residual sum-of-squares: 0.03913122 > ----------- Which seems great, but I'd like to be able to plot this curv...
2008 Apr 18
1
Overall p-value from a factor in a coxph fit
Hi all. If I run the simple regression when x is a categorical variable ( x <- factor(x) ): > MyFit <-coxph( Surv(start, stop, event) ~ x ) How can I get the overall p-value on x other than for each dummy variable? > anova(MyFit) does NOT provide that information as previously suggested on the list. All the best, Kare [[alternative HTML version deleted]]
2005 Apr 12
2
Perhaps Off-topic lme question
A question on lme() : details: nlme() in R 2.1.0 beta or 2.0.1 The data,y, consisted of 82 data value in 5 groups of sizes 3 9 8 28 34 . I fit a simple one level random effects model by: myfit <- lme( y~1, rand = ~1|Group) The REML estimates of between and within Group effects are .0032 and .53, respectively; the between group component is essentially zero as is clearly evident from a plot of the data. So, thus far, no problem. However, the confidence interval for the between Groups...