search for: fit1

Displaying 20 results from an estimated 355 matches for "fit1".

Did you mean: fit
2013 Feb 08
3
On p-values presented in the summary of Linear Models
Dear list members I have a doubt on how p-values for t-statistics are calculated in the summary of Linear Models. Here goes an example: x <- rnorm(100,50,10) y <- rnorm(100,0,5) fit1<-lm(y~x) summary(fit1) summary(fit1)$coef[2] # b summary(fit1)$coef[4] # Std. Error summary(fit1)$coef[6] # t-statistic summary(fit1)$coef[8] # Pr(>|t| summary(fit1)$df [2] # degrees of freedom # t-statistic can be calculated as: t<-(summary(fit1)$coef[2])/summary(fit1)$coef[4] t # t-stat...
2005 Jul 21
1
About object of class mle returned by user defined functions
...lower = optim.lower, upper = optim.upper, ... ) } ## End of conditional on all(is.infinite(c(optim.lower,optim.upper))) getFit } It seems to work fine on examples like: > isi1 <- rgamma(100, shape = 2, scale = 1) > fit1 <- newFit(isi1) ## fitting here with the "correct" density (initial parameters are obtained by the method of moments) > coef(fit1) shape scale 1.8210477 0.9514774 > vcov(fit1) shape scale shape 0.05650600 0.02952371 scale 0.02952371 0.02039714 > log...
2009 Apr 15
2
AICs from lmer different with summary and anova
...','y' )))) id=rep(1:120,2); datx=cbind(id,datx) #give x1 a slight relation with y (only necessary to make the random effects non-zero in this artificial example) datx$x1=(datx$y*0.1)+datx$x1 library(lme4) #fit the data fit0=lmer(y~x1+x2+(1|id), data=datx); print(summary(fit0),corr=F) fit1=lmer(y~x1+x2+(1+x1|id), data=datx); print(summary(fit1),corr=F) #compare the models anova(fit0,fit1) Now, look at the output, below. You can see that the AIC from "print(summary(fit0))" is 87.34, but the AIC for fit0 in "anova(fit0,fit1)" is 73.965. There are similar changes...
2011 Mar 25
2
A question on glmnet analysis
...,x8,x9,x10,x11,x12,x13,x14,x15), 104, 15) y <- outcome library(glmnet) fit.1 <- glmnet(x15std, y, family="binomial", standardize=FALSE) fit.1cv <- cv.glmnet(x15std, y, family="binomial", standardize=FALSE) default alpha=1, so this should be lasso penalty. Coefficients.fit1 <- coef(fit1, s=fit1.cv$lambda.min) Active.Index.fit1 <- which(Coefficients.fit1 !=0) Active.Coefficients.fit1 <- Coefficients.fit1[Active.Index.fit1] Active.Index.fit1 [1] 1 5 9 10 16 Active.Coefficients.fit1 [1] -1.28774827 0.01420395 0.70444865 -0.27726625 0.18455926 My optimal m...
2004 Jun 11
1
comparing regression slopes
...some R-code of Spencer Graves in reply to a similar problem: http://www.mail-archive.com/r-help at stat.math.ethz.ch/msg06666.html The code was: > df1 <- data.frame(x=1:10, y=1:10+rnorm(10)) #3observations in original code > df2 <- data.frame(x=1:10, y=1:10+rnorm(10)) > > fit1 <- lm(y~x, df1) > s1 <- summary(fit1)$coefficients > fit2 <- lm(y~x, df2) > s2 <- summary(fit2)$coefficients > > db <- (s2[2,1]-s1[2,1]) > sd <- sqrt(s2[2,2]^2+s1[2,2]^2) > df <- (fit1$df.residual+fit2$df.residual) > td <- db/sd > 2*pt(-ab...
2012 Nov 08
2
Comparing nonlinear, non-nested models
..., 0.41, 0.49, 0.58, 0.61, 0.71, 0.83, 0.98, 1.03, 1.06) model1 <- 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, fit...
2004 Dec 13
1
AIC, glm, lognormal distribution
I'm attempting to do model selection with AIC, using a glm and a lognormal distribution, but: fit1<-glm(BA~Year,data=pdat.sp1.65.04, family=gaussian(link="log")) ## gives the same result as either of the following: fit1<-glm(BA~Year,data=pdat.sp1.65.04, family=gaussian) fit1<-lm(BA~Year,data=pdat.sp1.65.04) fit1 #Coefficients: #(Intercept) Year2004 # -1.6341 -0.2...
2008 Jan 05
1
Likelihood ratio test for proportional odds logistic regression
Hi, I want to do a global likelihood ratio test for the proportional odds logistic regression model and am unsure how to go about it. I am using the polr() function in library(MASS). 1. Is the p-value from the likelihood ratio test obtained by anova(fit1,fit2), where fit1 is the polr model with only the intercept and fit2 is the full polr model (refer to example below)? So in the case of the example below, the p-value would be 1. 2. For the model in which there is only one independent variable, I would expect the Wald test and the likelihood ratio...
2010 Nov 10
1
standardized/studentized residuals with loess
Hi all, I'm trying to apply loess regression to my data and then use the fitted model to get the *standardized/studentized residuals. I understood that for linear regression (lm) there are functions to do that:* * * fit1 = lm(y~x) stdres.fit1 = rstandard(fit1) studres.fit1 = rstudent(fit1) I was wondering if there is an equally simple way to get the standardized/studentized residuals for a loess model? BTW my apologies if there is something here that I'm missing. All the best, * * *Oliver * [[alternative HT...
2012 May 28
0
GLMNET AUC vs. MSE
...[[i]], alpha=.05, type="mse", nfolds=10, standardize=TRUE,family="binomial") c_output = c(i,fit$cvlo[fit$lambda==fit$lambda.1se],fit$cvm[fit$lambda==fit$lambda.1se], fit$cvup[fit$lambda==fit$lambda.1se]) names(c_output) = names(output_x) output_x = rbind(output_x, t(c_output)) fit1=cv.glmnet(as.matrix(yc[[i]]), y=xc[[i]], alpha=.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...
2011 Oct 06
1
anova.rq {quantreg) - Why do different level of nesting changes the P values?!
...the comparison of model 1 and model 2 would remain the same, whether or not I add a third model to be compared with. However, the P values change, and I do not understand why. Here is an example code (following with it's input): data(barro) fit0 <- rq(y.net ~ lgdp2 + fse2 , data = barro) fit1 <- rq(y.net ~ lgdp2 + fse2 + gedy2 , data = barro) fit2 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 , data = barro) anova(fit0,fit1,fit2, R = 1000) anova(fit0,fit1, R = 1000) Output: > data(barro) > fit0 <- rq(y.net ~ lgdp2 + fse2 , data = barro) > fit1 <- rq(y.net ~ lgdp2...
2011 Jan 24
5
Train error:: subscript out of bonds
...or in indexes[[j]] : subscript out of bounds?. For example when I set seed to 357 following code produced result only for 8 iterations and for 9th iteration it reaches to an error that ?subscript out of bonds? error. I don?t understand why Any help would be great thanks ####### for (i in 1:10) { fit1<-NULL; x<-NULL; x<-which(number==i) trainset<-d[-x,] testset<-d[x,] train1<-trainset[,-ncol(trainset)] train1<-train1[,-(1)] test_t<-testset[,-ncol(testset)] species_test<-as.factor(testset[,ncol(testset)]) test_t<-test_t[,-(1)] #### #CARET::TRAIN #### fit...
2008 Feb 23
3
using subset() in data frame
...5 2 inrow macro . . . . . . . . . . 7 inrow micro 8 inrow micro Now I want to do separate lm's for each case of porosity, macro and micro. The code as given in MASS, p.141, slightly modified would be: fit1 <- lm(y ~ x, data=data.b, subset = porosity == "macro") fit2 <- update(fit1, subset = porosity == "micro") ###simplest code with subscripting fit1 <- lm(y ~ x, data.b[porosity=="macro"]) ###following example in ?subset fit1 <- lm(y ~ x, data.b, subset(dat...
2009 Feb 12
0
Comparing slopes in two linear models
...e diferents. I've looked trought the support list for methods for comparing slopes and found the three explained above: #d - whole datafrmae d$Local <- as.factor(d$Local) dHT <- subset(d, Local!='Palm') dP <- subset(d, Local!='Palm') 1 - Single dataframe procedure: fit1 <- lm(log(varCDI) ~ Local + I(log(CDI)) + Local:I(log(CDI)), data=d) fit2 <- lm(log(varCDI) ~ Local + I(log(CDI)) + Local:I(log(CDI)), data=dHT) a1 <- anova(fit1) a2 <- anova(fit2) a1 Local:I(log(CDI)) 2 1.183 0.592 7.8741 0.0005574 *** Residuals 152 11.421 0.075 a...
2008 Dec 01
1
Comparing output from linear regression to output from quasipoisson to determine the model that fits best.
...sion (gaussian(link = "identity")) the other a quasipoisson(link = "log"). I have log likelihoods from each model. Is there any way I can determine which model is a better fit to the data? anova() does not appear to work as the models have the same residual degrees of freedom: fit1<-glm(PHYSFUNC~HIV,data=KA) summary(fit1) fitQP<-glm(PHYSFUNC~HIV,data=KA,family=quasipoisson) summary(fitQP) anova(fit1,fitOP) Program OUTPUT: > fit1<-glm(PHYSFUNC~HIV,data=KA) > summary(fit1) Call: glm(formula = PHYSFUNC ~ HIV, data = KA) Deviance Residuals: Min 1Q M...
2008 Apr 17
1
survreg() with frailty
...r R-users, I have noticed small discrepencies in the reported estimate of the variance of the frailty by the print method for survreg() and the 'theta' component included in the object fit: # Examples in R-2.6.2 for Windows library(survival) # version 2.34-1 (2008-03-31) # discrepancy fit1 <- survreg(Surv(time, status) ~ rx + frailty(litter), rats) fit1 fit1$history[[1]]$theta # OK fit2 <- survreg(Surv(time, status) ~ rx + frailty(litter, df = 13), rats) fit2 fit2$history[[1]]$theta # discrepancy fit3 <- survreg(Surv(time, status)~ age + sex + frailty(id), kidney) fit3 fi...
2009 May 05
2
Stepwise logistic Regression with significance testing - stepAIC
...optimal model. However I am not sure if stepAIC considers significance properties like Likelihood ratio test and Wald test (see example below).     > y <- rbinom(30,1,0.4) > x1 <- rnorm(30) > x2 <- rnorm(30) > x3 <- rnorm(30) > xdata <- data.frame(x1,x2,x3) > > fit1 <- glm(y~ . ,family="binomial",data=xdata) > stepAIC(fit1,trace=FALSE)   Call:  glm(formula = y ~ x3, family = "binomial", data = xdata)   Coefficients: (Intercept)           x3      -0.3556       0.8404    Degrees of Freedom: 29 Total (i.e. Null);  28 Residual Null Dev...
2009 Apr 08
2
Null-Hypothesis
...n the following statement : t = (b1 - b2) / sb1,b2 where b1 and b2 are the two slope coefficients and sb1,b2 the pooled standard error of the slope (b) which can be calculated in R this way: > df1 <- data.frame(x=1:3, y=1:3+rnorm(3)) > df2 <- data.frame(x=1:3, y=1:3+rnorm(3)) > fit1 <- lm(y~x, df1) > s1 <- summary(fit1)$coefficients > fit2 <- lm(y~x, df2) > s2 <- summary(fit2)$coefficients > db <- (s2[2,1]-s1[2,1]) > sd <- sqrt(s2[2,2]^2+s1[2,2]^2) > df <- (fit1$df.residual+fit2$df.residual) > td <- db/sd > 2*pt(-abs(td),...
2020 Sep 29
5
2 KM curves on the same plot
Hello, Can anyone suggest a 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 c...
2011 Jan 21
2
Looping with incremented object name and increment function
Folks, I am trying to get a loop to run which increments the object name as part of the loop. Here "fit1" "fit2" "fit3" and "fit4" are linear regression models that I have created. > for (ii in c(1:4)){ + SSE[ii]=rbind(anova(fit[ii])$"Sum Sq") + dfe[ii]=rbind(summary(fit[ii])$df) + } Error in anova(fit[ii]) : object 'fit' not found Why isn'...