search for: fit2

Displaying 20 results from an estimated 278 matches for "fit2".

Did you mean: fit
2013 May 05
1
slope coefficient of a quadratic regression bootstrap
...slope coefficent step 3 find out the sampling distribution above and calculate the % =0 step 4 multiple the % by 2 However, I am new to the package boot. I wrote a code for step 1 and got a error message. Please kindly advise how to modify it and thank you. Elaine code require(boot) function.fit2 <- function(data){ #data <- data[indices,] # select obs. in bootstrap sample fit2 <-lm(logDIS~logBMN+I(logBMN^2)) coefficients(fit2) # return coefficient vector } boot.fit2 <- boot(dataN, function.fit2, 1000) error > fit2....
2011 May 01
1
Different results of coefficients by packages penalized and glmnet
Dear R users: Recently, I learn to use penalized logistic regression. Two packages (penalized and glmnet) have the function of lasso. So I write these code. However, I got different results of coef. Can someone kindly explain. # lasso using penalized library(penalized) pena.fit2<-penalized(HRLNM,penalized=~CN+NoSus,lambda1=1,model="logistic",standardize=TRUE) pena.fit2 coef(pena.fit2) opt<-optL1(HRLNM,penalized=~CN+NoSus,fold=5) opt$lambda coef(opt$fullfit) prof<-profL1(HRLNM,penalized=~CN+NoSus,fold=opt$fold,steps=20) plot(prof$lambda, prof$cvl, type=&q...
2009 Feb 19
1
Read.table not reading in all columns
Hello, I am reading in a file called fit2.txt (Limma). fit2.txt has 38 columns but when I dim(fit2) I only get 6 columns. The first column that it does not read in is df.residual. fit2<-read.table(fit2, file="fit2.txt",sep="\t",quote="",comment.char="",as.is=TRUE) The first few lines of fit2....
2010 Mar 17
1
accessing info in object slots from listed objects using loops
Hey, I have stacked a couple of garchFit objects in a list with names $fit1, $fit2, ..., $fiti assigning objects names using a loop, i.e. after running the loop modelStack = list($fit1, $fit2,...,$fiti). Thus the following apply; a = modelStack$fit2, then a is the second garchFit object of formal class 'fGarch' with 11 slots, @call, @formula... etc. I then want to extra...
2017 Dec 20
1
Nonlinear regression
...;- 1/intercept1 >Kl <- .735011*Qmax > >xlim <- range(ce, celin) >ylim <- range(qe, qelin) > >abline(lm(qelin ~ celin)) > >c <- seq(min(ce), max(ce)) >q <- (Qmax*Kl*c)/(1+(Kl*c)) > >lines(c, q) > > >##My attempt at the nonlinear regression >fit2 <- nls(qe ~ ((Qmax*Kl*ce)/(1+(Kl*ce))), start = list(Qmax = Qmax, >Kl = >Kl)) >results <- fit2$m$getpars() >Qmax2 <- fit2$m$getpars()[1] >Kl2 <- fit2$m$getpars()[2] >summary(fit2) > >-Timothy
2009 Feb 12
0
Error Message: Error in dim(data) <- dim : attempt to set an attribute on NULL
...Set, design) cont.matrix<-makeContrasts(s0vss24=s.0-s.24, s24vss48=s.24-s.48, s48vss96=s.48-s.96, c0vsc24=c.0-c.24, c24vsc48=c.24-c.48, c48vsc96=c.48-c.96, levels=design) write.table(cont.matrix,file="cont.matrix.txt",sep="\t",col.names=NA) # estimate the contrasts and put in fit2 fit2 <- contrasts.fit(fit, cont.matrix) fit2 <- eBayes(fit2) #print fit2 table write.table(fit2,file="fit2.txt",sep="\t") #I took the fit2 table and manually removed all empty and GFP rows, plus I deleted all rows where the Fpval was greated than 0.01. This table is cal...
2011 Mar 25
2
A question on glmnet analysis
...tercept as first one. Second, I did the same things with alpha=0.5 option to do elastic net analysis. fit.2 <- glmnet(x15std, y, family="binomial", standardize=FALSE, alpha=0.5) fit.2cv <- cv.glmnet(x15std, y, family="binomial", standardize=FALSE, alpha=0.5) Coefficients.fit2 <- coef(fit2, s=fit2.cv$lambda.min) Active.Index.fit2 <- which(Coefficients.fit2 !=0) Active.Coefficients.fit2 <- Coefficients.fit2[Active.Index.fit2] Active.Index.fit2 [1] 1 5 9 10 16 Active.Coefficients.fit2 [1] -1.3286190 0.1410739 0.6315108 -0.2668022 0.2292459 This model chose...
2020 Sep 29
5
2 KM curves on the same plot
...simple way to generate a Kaplan-Meier plot with 2 survfit objects, just like this one:? https://drive.google.com/file/d/1fEcpdIdE2xYtA6LBQN9ck3JkL6-goabX/view?usp=sharing Suppose I have 2 survfit objects: fit1 is for the curve on the left (survtime has been truncated to the cutoff line: year 5), fit2 is for the curve on the right (minimum survival time is at the cutoff line: year 5), but if I do the following: plot(fit1, col=1:2) lines(fit2,col=1:2) Then I will have an horizontal line on the top that connect from 0 to 4 years, which I do not want that to be drawn (see blue arrow below): http...
2011 May 29
1
Fitting spline using Pspline
...seems to work fine for a data set of size n=4476, but not for anything larger (say, n=4477). For example: THIS WORKS: ----------------------------- random = array(0,c(4476,2)) random[,1] = runif(4476,0,1) random[,2] = runif(4476,0,1) random = random[order(random[,1]),] plot(random[,1],random[,2]) fit2 = sm.spline(random[,1],random[,2], norder=2, cv=FALSE) lines(fit2$x,fit2$y) THIS FAILS: ----------------------------- random = array(0,c(4477,2)) random[,1] = runif(4477,0,1) random[,2] = runif(4477,0,1) random = random[order(random[,1]),] plot(random[,1],random[,2]) fit2 = sm.spline(random[,1],ra...
2009 Jul 28
2
A hiccup when using anova on gam() fits.
I stumbled across a mild glitch when trying to compare the result of gam() fitting with the result of lm() fitting. The following code demonstrates the problem: library(gam) x <- rep(1:10,10) set.seed(42) y <- rnorm(100) fit1 <- lm(y~x) fit2 <- gam(y~lo(x)) fit3 <- lm(y~factor(x)) print(anova(fit1,fit2)) # No worries. print(anova(fit1,fit3)) # Likewise. print(anova(fit2,fit3)) # Throws an error. print(anova(fit3,fit2)) # ``Works'' but gives negative degrees of freedom and sum of squares. Is this evidence of a ``bug'...
2009 May 12
1
questions on rpart (tree changes when rearrange the order of covariates?!)
...ne. The misclassification tables are different too. I did not change the data, but why the results are so different? Does anyone know how rpart deal with ties? Here is the codes for running the two trees. library(mlbench) data(PimaIndiansDiabetes2) mydata<-PimaIndiansDiabetes2 library(rpart) fit2<-rpart(diabetes~., data=mydata,method="class") plot(fit2,uniform=T,main="CART for original data") text(fit2,use.n=T,cex=0.6) printcp(fit2) table(predict(fit2,type="class"),mydata$diabetes) ## misclassifcation table: rows are fitted class neg pos neg 437 68...
2010 Apr 01
1
predicted time length differs from survfit.coxph:
Hello All, Does anyone know why length(fit1$time) < length(fit2$n) in survfit.coxph output? Why is the predicted time length is not the same as the number of samples (n)? I tried: example(survfit.coxph). Thanks, parmee > fit2$n [1] 241 > fit2$time [1] 0 31 32 60 61 152 153 174 273 277 362 365 499 517 518 547 [17]...
2011 Jan 26
2
Extracting the terms from an rpart object
Hello all, I wish to extract the terms from an rpart object. Specifically, I would like to be able to know what is the response variable (so I could do some manipulation on it). But in general, such a method for rpart will also need to handle a "." case (see fit2) Here are two simple examples: fit1 <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis) fit1$call fit2 <- rpart(Kyphosis ~ ., data=kyphosis) fit2$call Is there anything "prettier" then using string manipulation? Thanks. ----------------Contact Details:---------------...
2012 Nov 08
2
Comparing nonlinear, non-nested models
...lt;- function(x, xo, ym) ym * (x-xo)/x model2 <- function(x, xo, ym, k) ym * (x-xo)/(k+x-xo) model3 <- function(x, xo, ym) ym * (1-exp(-log(2)*(x-xo)/xo)) model4 <- function(x, xo, ym, k) ym * (1-exp(-log(2)*(x-xo)/k)) fit1 <- nls(y~model1(x, xo, ym), start=list(xo=0.5, ym=1)) fit2 <- nls(y~model2(x, xo, ym, k), start=list(xo=0.5, ym=1, k=1)) fit3 <- nls(y~model3(x, xo, ym), start=list(xo=0.5, ym=1)) fit4 <- nls(y~model4(x, xo, ym, k), start=list(xo=0.5, ym=1, k=1)) anova(fit1, fit2) anova(fit3, fit4) Models 1 and 2 are nested, as are models 3 and 4 (set k=xo),...
2009 May 04
1
Nelson-Aalen estimator of cumulative hazard
...the reason for the discrepancy? require(foreign) gb <- read.dta("GB.dta") # Green & Byar data; N = 483 # Method 1 fit1 <- coxph( Surv(time, status=="Cancer" | status=="CVD" | status=="Other") ~ 1, data=gb) h1 <- basehaz(fit1) # Method 2 fit2 <- survfit(Surv(time, status=="Cancer" | status=="CVD" | status=="Other") ~ 1, data=gb) jump <- fit2$n.event > 0 h2 <- cumsum(fit2$n.event[jump]/fit2$n.risk[jump]) plot(h1$time, h1$hazard - h2) Thank you, Ravi. _________________________________________...
2010 Mar 29
1
stuck with affy / limma
...he gene symbol ### limma contrasts design <- model.matrix(~ -1+factor(c(1,1,1,2,2,2,3,3,3))) colnames(design) <- c("control", "three", "six") fit <- lmFit(x, design) meanSdPlot(x) contrast.matrix <- makeContrasts(three-control, six-control, levels=design) fit2 <- contrasts.fit(fit, contrast.matrix) fit2 <- eBayes(fit2) #### top list topTable(fit2, coef=1, adjust="BH", number=20, sort.by="M") library(hgu133plus2.db) u<-mget(row.names(fit2),hgu133plus2SYMBOL) How can I produce a topTable result with according gene names, someh...
2017 Dec 20
0
Nonlinear regression
...- range(ce, celin) > >ylim <- range(qe, qelin) > > > >abline(lm(qelin ~ celin)) > > > >c <- seq(min(ce), max(ce)) > >q <- (Qmax*Kl*c)/(1+(Kl*c)) > > > >lines(c, q) > > > > > >##My attempt at the nonlinear regression > >fit2 <- nls(qe ~ ((Qmax*Kl*ce)/(1+(Kl*ce))), start = list(Qmax = Qmax, > >Kl = > >Kl)) > >results <- fit2$m$getpars() > >Qmax2 <- fit2$m$getpars()[1] > >Kl2 <- fit2$m$getpars()[2] > >summary(fit2) > > > >-Timothy > [[alternative HTML versi...
2012 May 28
0
GLMNET AUC vs. MSE
...05, type="auc", nfolds=10, standardize=TRUE,family="binomial") c_output1 = c(i,fit1$cvlo[fit1$lambda==fit1$lambda.1se],fit1$cvm[fit1$lambda==fit1$lambda.1se], fit1$cvup[fit1$lambda==fit1$lambda.1se]) names(c_output1) = names(output_x1) output_x1 = rbind(output_x1, t(c_output1)) fit2=cv.glmnet(as.matrix(yc[[i]]), y=xc[[i]], alpha=.05, type="class", nfolds=10, standardize=TRUE,family="binomial") c_output2 = c(i,fit2$cvlo[fit2$lambda==fit2$lambda.1se],fit2$cvm[fit2$lambda==fit2$lambda.1se], fit2$cvup[fit2$lambda==fit2$lambda.1se]) names(c_output2) = names(outp...
2017 Dec 20
1
Nonlinear regression
...ce + KL * ce*qe and fit a non-intercept linear model to predict qe by ce and ce*qe. From this model I would then determine starting values for nls(). It seems to work with your data set: R> ce <- c(15.17, 42.15, 69.12, 237.7, 419.77) R> qe <- c(17.65, 30.07, 65.36, 81.7, 90.2) R> fit2 <- lm(qe ~ ce + I(ce*qe) - 1) R> summary(fit2) R> Kl <- - coef(fit2)[2] R> Qmax <- coef(fit2)[1]/Kl R> plot(ce, qe) R> c <- seq(min(ce), max(ce)) R> q <- (Qmax*Kl*c)/(1+(Kl*c)) R> lines(c, q) R> fit2 <- nls(qe ~ ((Qmax*Kl*ce)/(1+(Kl*ce))), start = list(Qmax...
2011 Apr 02
3
Plotting MDS (multidimensional scaling)
...n, MDS should reproduce the rectangular triangle ABD and the equilateral triangle ABC within it. However, even though distance matrix d2 below still indicates that ABC is an equilateral triangle, the plot of the MDS does not confirm this. x=c(0,2,1,0,0,0,sqrt(3),2*sqrt(3)) dim(x)=c(4,2) d2=dist(x) fit2<-isoMDS(d2) plot(fit2$points, xlab="Coordinate 1", ylab="Coordinate 2", main="Metric MDS",type="n") text(fit2$points, labels = c('A','B','C','D'), cex=1) The reason for this is that the dimension of the plot is automatic...