search for: sfit

Displaying 20 results from an estimated 20 matches for "sfit".

Did you mean: fit
2007 Mar 09
2
Extracting the p of F statistics from lm
I need to extract the p value from a ANOVA done with lm model fitting <- lm(var ~ group) Sfitting <- summary(fitting) Sfitting[10][1] gives the F value and the degrees of freedom but I am not able to get the p value. The function df should give a p value given a F but I am not able to make it work. I found only something about aov in the R help and I am not able to make it work Mass...
2011 Apr 05
6
simple save question
Hi, When I run the survfit function, I want to get the restricted mean value and the standard error also. I found out using the "print" function to do so, as shown below, print(km.fit,print.rmean=TRUE) Call: survfit(formula = Surv(diff, status) ~ 1, type = "kaplan-meier") records n.max n.start events *rmean *se(rmean) median 200.000
2012 May 16
1
survival survfit with newdata
...100,20) > time<-runif(100,min=0,max=7) > status<-sample(c(0,1), 100, replace = TRUE) > trainX<-x[11:100,] > trainTime<-time[11:100] > trainStatus<-status[11:100] > testX<-x[1:10,] > coxph.model<- coxph(Surv(trainTime,trainStatus)~ trainX) > sfit<- survfit(coxph.model,newdata=data.frame(testX)) > dim(sfit$surv) [1] 90 90 [[alternative HTML version deleted]]
2013 Nov 04
0
Fwd: Re: How to obtain nonparametric baseline hazard estimates in the gamma frailty model?
-------- Original Message -------- Subject: Re: How to obtain nonparametric baseline hazard estimates in the gamma frailty model? Date: Mon, 04 Nov 2013 17:27:04 -0600 From: Terry Therneau <therneau.terry at mayo.edu> To: Y <yuhanusa at gmail.com> The cumulative hazard is just -log(sfit$surv). The hazard is essentially a density estimate, and that is much harder. You'll notice that everyone does CDF curves for survival data ( Kaplan-Meier = estimate of 1-CDF), but no one does histograms, which estimate a density. That isn't because we wouldn't like density estimates....
2012 Oct 11
2
Question on survival
Hi, I'm going crazy trying to plot a quite simple graph. i need to plot estimated hazard rate from a cox model. supposing the model i like this: coxPhMod=coxph(Surv(TIME, EV) ~ AGE+A+B+strata(C) data=data) with 4 level for C. how can i obtain a graph with 4 estimated (better smoothed) hazard curve (base-line hazard + 3 proportional) to highlight the effect of C. thanks!! laudan [[alternative
2012 May 07
1
estimating survival times with glmnet and coxph
...00 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 [... truncated] # take test covariates for which beta is not zero selectedTestX <- x[1,nonzero.coef] # find survival curve for test subject sfit<- survfit(coxph.model,newdata=selectedTestX) cat("\ntime ") cat(sfit$time) cat("\nsurvival ") cat(sfit$surv)
2007 Dec 17
2
Capture warning messages from coxph()
Hi, I want to fit multiple cox models using the coxph() function. To do this, I use a for-loop and save the relevant results in a separate matrix. In the example below, only two models are fitted (my actual matrix has many more columns), one gives a warning message, while the other does not. Right now, I see all the warning message(s) after the for-loop is completed but have no idea which model
2004 Jul 04
2
smooth non cumulative baseline hazard in Cox model
...ox model but I think they were all on cumulative baseline hazard, for instance http://tolstoy.newcastle.edu.au/R/help/01a/0464.html http://tolstoy.newcastle.edu.au/R/help/01a/0436.html "basehaz" in package survival seems to do a cumulative hazard. extract from the basehaz function: sfit <- survfit(fit) H <- -log(sfit$surv) Since sfit$surv is monotonic, H will be monotonic too, which makes me think it is a cumulative function. I think H(t) it is the "sum" ("integration") of lambda's from 0 to t (Am I right?) What I need might be lambda(t) or lamb...
2008 Feb 25
0
logLik calculation in gls (nlme)
...# nlme likes to have data= specified ## fit true model library(nlme) g1 = gnls(y~a*exp(-b*x), start=list(a=1,b=2), weights=varPower(form=~fitted(.)), data=dat) expdev = -2*logLik(g1) ## Fitting the true model recovers ## the true parameters nicely: coef(g1) ## Fit a series of splines: sfit <- function(d) { form <- bquote(y~ns(x,df=.(d))) gls(eval(form), weights=varPower(form=~fitted(.)), data=dat) } spline_df = c(3:15,20,25,40) spline_list = lapply(as.list(spline_df),sfit) ## calculate deviances: spline_dev = -2*sapply(spline_list,logLik) plot(splin...
2005 Jun 24
1
"Error in contrasts" in step wise regression
Hi, I have a problem in getting step function work. I am getting the following error: > fit1 <- lm(Response~1) > fmla <- as.formula(paste(" ~ ",paste(colnames,collapse="+"))) > sfit <- step(fit1,scope=list(upper= fmla,lower= ~1),k=log(nrow(dat))) Start: AIC= -1646.66 Response ~ 1 Error in "contrasts<-"(`*tmp*`, value = "contr.treatment") : contrasts can be applied only to factors with 2 or more levels But if i count the unique values in...
2012 May 12
1
access the se of a forecast
Hi everybody, I am currently trying to forecast some double seasonal time series by using the function dshw. I want to access the standard errors to build the confident interval for my forecast. I am using to following code : fit<-dshw(eem,period1=7,period2=48,h=48) then by using summary(fit), I see that my se are contained in the vector : $s20 but when I call fit$s20, I get NULL. I
2017 Nov 07
0
Survfit when new data has only 1 row of data
...survfit. I want to make predictions for each individual, therefore, I have tried this code: trialnos <- unique(bdat5$trialno) prob0 <- function(ids,dataset,model,time){ probs <- rep(0,length(ids)) for(i in 1:length(ids)){ print(i) sdata <- subset(dataset,trialno==ids[i]) sfit <- survfit(model,newdata=sdata) probs[i] <-sum(summary(sfit,time)$surv) } return(probs) } prob0ests <- prob0(trialnos,bdat5,cfitcp2,730) When I do this for the first three trial numbers I get: 0.3001021 2993.4531767 0.3445589 The unusually large "probability" arises...
2008 Aug 12
2
ANOVA tables - storing F values
When I run a summary(anova) I get output for all of the elements (columns) as these are multiple - single anova results. Can I store the F values? I can't find the attribute of the fitted model attributes(fit) that stores these F values, and for that matter, P values. Thanks -- Gareth Campbell PhD Candidate The University of Auckland P +649 815 3670 M +6421 256 3511 E
2009 Dec 22
1
Slow survfit -- is there a faster alternative?
Using R 2.10 on Windows: I have a filtered database of 650k event observations in a data frame with 20+ variables. I'd like to be able to quickly generate estimate and plot survival curves. However the survfit and cph() functions are extremely slow. As an example: I tried results.cox<-coxph(Surv(duration, success) ~ start_time + factor1+ factor2+ variable3, data=filteredData) #(took a
2010 Oct 27
2
coxph linear.predictors
I would like to be able to construct hazard rates (or unconditional death prob) for many subjects from a given survfit. This will involve adjusting the ( n.event/n.risk) with (coxph object )$linear.predictors I must be having another silly day as I cannot reproduce the linear predictor: fit <- coxph(Surv(futime, fustat) ~ age, data = ovarian) fit$linear.predictors[1] [1] 2.612756
2006 Oct 31
2
Put a normal curve on plot
I would like to be able to place a normal distribution surrounding the predicted values at various places on a plot. Below is some toy code that creates a scatterplot and plots a regression line through the data. library(MASS) mu <- c(0,1) Sigma <- matrix(c(1,.8,.8,1), ncol=2) set.seed(123) x <- mvrnorm(50,mu,Sigma) plot(x) abline(lm(x[,2] ~ x[,1])) Say I want to add a normal
2007 Jul 27
4
Q: extracting data from lm
Warning: I am a complete newbie to R. I have read ISwR, but I am still finding myself completely stuck on some simple concepts. I have tried everything I can think of to solve this one, and finally decided that enough was enough and I need a pointer to a solution. I have the following summary from lm(): ---- > summary(lm(nu1~nu4)) Call: lm(formula = nu1 ~ nu4) Residuals: Min 1Q
2009 Nov 03
2
about the cox result
Hi all: I finished cox analysis like this: fit_cox<-coxph(Surv(dat$Time, dat$death) ~ dat$CD4 + strata(dat$gender),data=dat); > fit_cox Call: coxph(formula = Surv(data_ori$Time, data_ori$death) ~ data_ori$drug + strata(data_ori$gender), data = data_ori) coef exp(coef) se(coef) z p data_ori$drugddI 0.216 1.24 0.146 1.47 0.14 Likelihood ratio test=2.17 on
2009 Oct 23
1
coxph() and survfit()
...f survfit() when I supply a Cox model. Lets say for example: library(survival) fit <- coxph(Surv(time, status == 2) ~ factor(spiders), data = pbc) fit # HR for spiders is significant newdata <- data.frame(spiders = factor(0:1)) sf <- survfit(fit, newdata = newdata) sum.sf <- summary(sfit, times = c(2000, 2500, 3000)) # survival estimates for the yes/no spiders # and the 3 follow up times sum.sf$surv # corresponding lower limits of the # 95% CI sum.sf$low # corresponding upper limits of the # 95% CI sum.sf$up we observe that the 95% CIs overlap!! How is this possible since the...
2017 Jun 15
3
about fitting a regression line
Thanks for your replies. I tried the regression, but then got a NA value for the slope. And here is the error message: Coefficients: (1 not defined because of singularities) On Thu, Jun 15, 2017 at 12:20 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote: > Hi > > But X can be some function like - sin, cos, log, exp... > > Cheers > Petr > > > -----Original