Displaying 20 results from an estimated 10000 matches similar to: "Plotting linear fit"
2008 Aug 28
2
Spider Graph
Is there an R function to generate a radar or spider graph from a table
- e.g. radar(table(x)) or some such?
==================================================
Isaac T. Van Patten, Ph.D.
Professor
Department of Criminal Justice
Box 6934, Radford University
Radford, VA 24142
540-831-6148
ivanpatt@radford.edu <mailto:ivanpatt@radford.edu>
http://ivanpatt.asp.radford.edu
2011 Feb 01
1
dotchart {graphics} 2.11.1 vs. 2.12.1
I have a factor vector of subject races (Asian, Black, Hispanic, White; n=30) that I want to plot with a Cleveland dotplot or dotchart.
I tried the following in R2.12.1 :
> dotchart(table(school$Race))
Error in plot.xy(xy.coords(x, y), type = type, ...) : invalid plot type
Using the same data set in R2.11.1 the operation succeeded (I tried several variations to be sure):
>
2008 Dec 01
1
Comparing output from linear regression to output from quasipoisson to determine the model that fits best.
R 2.7
Windows XP
I have two model that have been run using exactly the same data, both fit using glm(). One model is a linear regression (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
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
#
2008 Aug 22
1
Help on competing risk package cmprsk with time dependent covariate
Dear R users,
I d like to assess the effect of "treatment" covariate on a disease relapse risk with the package cmprsk.
However, the effect of this covariate on survival is time-dependent
(assessed with cox.zph): no significant effect during the first year of follow-up,
then after 1 year a favorable effect is observed on survival (step
function might be the correct way to say that ?).
2010 Jun 07
1
fit data with y = x^-1
Dear list,
I am getting weired with fitting data with a 1/x-polynomial. Suggest I have
the following data:
x <- c(1,2,3,4,5,6,7)
y <- c(100,20,4,2,1,.3,.1)
I may fit this with a linear model
fit1 = lm(y ~ I(x))
Getting plot out of this model I applied
library(polynom)
pol1 = polynomial(fit1$coefficients)
f1 = as.function(pol1)
plot(x,y)
lines(x, f1(x), col = 2)
Clearly, this model
2007 Nov 23
1
intercept in lars fit
I am trying to extract coefficients from lars fit and can't find how to get
intercept. E.g.
y = rnorm(10)
x = matrix(runif(50),nrow=10)
X = data.frame(y,x)
fit1 = lars(as.matrix(X[,2:6]),as.matrix(X[,1]))
fit2 = lm(y~.,data=X)
Then, if I do:
> predict(fit1,s=1,mode='fraction',type='coefficients')$coef
X1 X2 X3 X4 X5
0.3447570
2011 Jan 05
1
Comparing fitting models
Dear all,
I have 3 models (from simple to complex) and I want to compare them in order to
see if they fit equally well or not.
From the R prompt I am not able to see where I can get this information.
Let´s do an example:
fit1<- lm(response ~ stimulus + condition + stimulus:condition, data=scrd)
#EQUIVALE A lm(response ~ stimulus*condition, data=scrd)
fit2<- lm(response ~ stimulus +
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)) #
2010 Sep 08
2
dataframe selection using a multi-value key
I am merging two dataframes using a relational key (incident number and
incident year), but not all the records match up. I want to be able to
review only the records that cannot be merged for each individual dataframe
(essentially trying to select records from one dataframe using a multi-value
relational key from the other dataframe). The following code shows what I
am trying to do. The final
2005 Jul 21
1
About object of class mle returned by user defined functions
Hi,
There is something I don't get with object of class "mle" returned by a
function I wrote. More precisely it's about the behaviour of method
"confint" and "profile" applied to these object.
I've written a short function (see below) whose arguments are:
1) A univariate sample (arising from a gamma, log-normal or whatever).
2) A character string
2008 Jun 04
2
linear model in the repeated data type~
here is the data:
y<-c(5,2,3,7,9,0,1,4,5)
id<-c(1,1,6,6,7,8,15,15,19)
t<-c(50,56,50,56,50,50,50,60,50)
table1<-data.frame(y,id,t)//longitudinal data
what I want to do is to use the linear model for each id ,then get the
estimate value,like:
fit1<-lm(y~t,data=table1,subset=(id==1))
but ,you can see the variable "id" is quite irregular,they are not arranaged
in order
2009 Jun 08
3
Plotting two regression lines on one graph
Hi!
I have fitted two glms assuming a poisson distribution which are:
fit1 <- glm(Aids ~ Year, data=aids, family=poisson())
fit2 <- glm(Aids ~ Year+I(Year^2), data=aids, family=poisson())
I am trying to work out how to represent the fitted regression curves of fit1 and fit2 on the one graph. I have tried:
graphics.off()
plot(Aids ~ Year, data = aids)
line(glm(Aids ~ Year,
2013 Feb 12
2
standard error very high in maximum liklihood fitting
Dear all,
I have been trying to fit my data (only right censored) with gumbel distribution using fitdistrplus. I am getting very high standard error. I have been wondering why.
The followings are the outputs:
fit1=fitdistcens(dr0, "gumbel", start=list(a=99, b=0.6), optim.method= "L-BFGS-B", lower = 0.0, upper = Inf)
> summary(fit1)
FITTING OF THE DISTRIBUTION ' gumbel
2009 Apr 15
2
AICs from lmer different with summary and anova
Dear R Helpers,
I have noticed that when I use lmer to analyse data, the summary function
gives different values for the AIC, BIC and log-likelihood compared with the
anova function.
Here is a sample program
#make some data
set.seed(1);
datx=data.frame(array(runif(720),c(240,3),dimnames=list(NULL,c('x1','x2','y'
))))
id=rep(1:120,2); datx=cbind(id,datx)
#give x1 a
2011 May 27
2
help with barplot
Hi,
I'm really struggling with barplot
I have a data.frame with 3 columns. The first column represents an
"incident" type
The second column represents a "month"
The third column represents a "time"
Code for a sample data.frame
incidents <- rep(c('a','b','d','e'), each =25)
months <- rep(c(1,2), each =10)
times
2011 Mar 25
2
A question on glmnet analysis
Hi,
I am trying to do logistic regression for data of 104 patients, which
have one outcome (yes or no) and 15 variables (9 categorical factors
[yes or no] and 6 continuous variables). Number of yes outcome is 25.
Twenty-five events and 15 variables mean events per variable is much
less than 10. Therefore, I tried to analyze the data with penalized
regression method. I would like please some of the
2011 Apr 02
3
Plotting MDS (multidimensional scaling)
Hi,
I just encountered what I thought was strange behavior in MDS. However, it
turned out that the mistake was mine. The lesson learned from my mistake is
that one should plot on a square pane when plotting results of an MDS. Not
doing so can be very misleading. Follow the example of an equilateral
triangle below to see what I mean. I hope this helps others to avoid this
kind of headache.
2004 Jun 11
1
comparing regression slopes
Dear List,
I used rlm to calculate two regression models for two data sets (rlm
due to two outlying values in one of the data sets). Now I want to
compare the two regression slopes. I came across 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))
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