Displaying 20 results from an estimated 900 matches similar to: "setting parameters equal in lm"
2009 Sep 14
3
Eliminate cases in a subset of a dataframe
Hi folks,
I created a subset of a dataframe (i.e., selected only men):
subdata <- subset(data,data$gender==1)
After a residual diagnostic of a regression analysis, I detected three
outliers:
linmod <- lm(y ~ x, data=subdata)
plot(linmod)
Say, the cases 11,22, and 33 were outliers.
Here comes the problem: When I want to exclude these three cases in a
further regression analysis,
- for
2011 Oct 18
1
cygwing warming when creating a package in windows
Dear All,
I am a beginner creating R packages. I followed the Leisch (2009) tutorial
and the document ?Writing R Extensions? to write an example.
I installed R 2.12.2 (I also tried R2.13.2), the last version of Rtools and
the recommended packages in a PC with Windows 7 Home Premium.
I can run R CMD INSTALL linmod in the command prompt and the R CMD check
linmod. The following outputs are
2013 Mar 12
1
Cook's distance
Dear useRs,
I have some trouble with the calculation of Cook's distance in R.
The formula for Cook's distance can be found for example here:
http://en.wikipedia.org/wiki/Cook%27s_distance
I tried to apply it in R:
> y <- (1:400)^2
> x <- 1:100
> lm(y~x) -> linmod # just for the sake of a simple example
>
2009 Oct 26
2
What is the most efficient practice to develop an R package?
I am reading Section 5 and 6 of
http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf
It seems that I have to do the following two steps in order to make an
R package. But when I am testing these package, these two steps will
run many times, which may take a lot of time. So when I still develop
the package, shall I always source('linmod.R') to test it. Once the
code in
2007 Jul 26
1
Regression with Missing values. na.action?
Hi all,
Can you please tell me what is the problem here.
My regression eq is y = B0 + B1X1 +B2X2 +e
And i am interested in coefficient B1
I am doing regression with two cases:
1) reg<-lm(y ~ X1 + X2, sam) where sam is the data
2) reg<-lm(y ~ X1 + X2, sam, na.action= na.exclude) . I have missing values
in X1
but the values of coefficient is not consistent in two cases.
Actually B1 in
2010 Sep 29
1
get response from a glm
Hi everyone:
¡¡I am new to R and I have a really basic question.
I have already got a generalized linear model from some dataset, say y=b0 + b1X1 + b2X2. Then I want to get the value of y provided, say, X1=1, X2=2. And the confidence Intervals of this y.
I know I can just calculate that since I know the model already. But is there some code that can calculate those automatically?
2010 Apr 27
3
Problem calculating multiple regressions on a data frame.
Hi there,
I am stuck trying to solve what should be a fairly easy problem.
I have a data frame that essentially consists of (ID, time as seqMonth,
variable, value) and i want to find the regression coefficient of value vs
time for each combination of ID and Variable.
I have tried several approaches and none of them seems to work as i
expected.
For example, i have tried:
2011 Jan 20
1
Constrained Regression
Hi everyone,
I'm trying to perform a linear regression y = b1x1 + b2x2 + b3x3 + b4x4 +
b5x5 while constraining the coefficients such that -3 <= bi <= 3, and the
sum of bi =1. I've searched R-help and have found solutions for
constrained regression using quadratic programming (solve.QP) where the
coefficients are between 0 and 1 and sum to 1, but unfortunately do not
understand
2006 Jan 11
1
updating formula inside function
Dear R-Helpers
Given a function like
foo <- function(data,var1,var2,var3) {
f <- formula(paste(var1,'~',paste(var2,var3,sep='+'),sep=''))
linmod <- lm(f)
return(linmod)
}
By typing
foo(mydata,'a','b','c')
I get the result of the linear model a~b+c.
How can I rewrite the function so that the formula can be updated inside
the function,
2012 Jul 09
1
linearHypothesis and factors
Hi everyone,
I'm sure this is pretty basic but I couldn't find a clear example of how to
do this. I'm running a regression, say:
reg <- lm(Y ~ x1 + year)
where x1 is a continuous variable and year is a factor with various year
levels. Individually, each year factor variable is not significant, but I
have a suspicion they are jointly significant. I can't figure out how to run
2010 Jun 18
1
How to calculate the robust standard error of the dependent variable
Hi, folks
linmod=y~x+z
summary(linmod)
The summary of linmod shows the standard error of the coefficients. How can
we get the sd of y and the robust standard errors in R?
Thanks!
[[alternative HTML version deleted]]
2010 Jun 21
2
How to predict the mean and variance of the dependent variable after regression
Hi, folks,
As seen in the following codes:
x1=rlnorm(10)
x2=rlnorm(10,mean=2)
y=rlnorm(10,mean=10)### Fake dataset
linmod=lm(log(y)~log(x1)+log(x2))
After the regression, I would like to know the mean of y. Since log(y) is
normal and y is lognormal, I need to know the mean and variance of log(y)
first. I tried mean (y) and mean(linmod), but either one is what I want.
Any tips?
Thanks in
2010 Feb 13
2
lm function in R
Hello,
I am trying to learn how to perform Multiple Regression Analysis in R. I
decided to take a simple example given in this PDF:
http://www.utdallas.edu/~herve/abdi-prc-pretty.pdf
I created a small CSV called, students.csv that contains the following data:
s1 14 4 1
s2 23 4 2
s3 30 7 2
s4 50 7 4
s5 39 10 3
s6 67 10 6
Col headers: Student id, Memory span(Y), age(X1), speech rate(X2)
Now
2012 Oct 09
1
car::linearHypothesis Sum of Sqaures Error?
I am working with a RCB 2x2x3 ANCOVA, and I have noticed a difference in the calculation of sum of squares in a Type III calculation.
Anova output is a follows:
> Anova(aov(MSOIL~Forest+Burn*Thin*Moisture+ROCK,data=env3l),type=3)
Anova Table (Type III tests)
Response: MSOIL
Sum Sq Df F value Pr(>F)
(Intercept) 22.3682 1 53.2141 3.499e-07 ***
Forest
2008 Mar 10
3
Weighting data when running regressions
Dear R-Help,
I'm new to R and struggling with weighting data when I run regression. I've
tried to use search to solve my problem but haven't found anything helpful
so far.
I (successfully) import data from SPSS (15) and try to run a linear
regression on a subset of my data file where WEIGHT is the name of my
weighting variable (numeric), e.g.:
library(foreign)
2011 Sep 22
1
Wrapper of linearHypothesis (car) for post-hoc of repeated measures ANOVA
For some time I have been looking for a convenient way of performing
post-hoc analysis to Repeated Measures ANOVA, that would be acceptable
if sphericity is violated (i.e. leaving aside post-hoc to lme models).
The best solution I found was John Fox's proposal to similar requests
in R-help:
http://tolstoy.newcastle.edu.au/R/e2/help/07/09/26518.html
2008 Aug 06
1
Variance-covariance matrix for parameter estimates
Dear All,
I am currently working with the coxph function within the package survival.
I have the model h_ij = h_0(t) exp(b1x1 + b2x2) where the indicator
variables
are as follows:
x1 x2
VPS 0 0
LTG 1 0
TPM 0 1
[[alternative HTML version deleted]]
2011 Mar 27
1
Sweave: include a multi-page-pdf plot
Hi,
I'm just starting out with Sweave, and I can't get a plot(linmod) to
display all four plots:
<< bild >>=
x1 <- runif(100)
x2 <- rexp(100)
y <- 3 + 4*x1 + 5*x2 + rnorm(100)
mod <- lm(y~x1+x2)
plot(mod)
@
Some Text
<<fig=TRUE>>=
<<bild>>
@
This plots only the first image of the four-page plot.lm() result.
I don't want to use
2009 Nov 05
2
Using a by() function to process several regression (lm()) functions
Hello,
Thank you very much for looking at this. I have a "seasonal" user for R. I
teach my undergrads and graduates students statistics using R and often find
myself trying to solve problems to process student collected data in an
efficient way.
In this case, I have a data.frame with multiple observations. These are gas
concentrations in a chamber and are used to measure into rates,
2015 Jun 26
1
[R-pkg-devel] Guidelines for S3 regression models
Stephen,
thanks for your effort. The more appropriate list for this discussion is
probably R-devel (as far as I understand it) so I've moved the discussion
there.
Related topics have already been discussed in the past. Specifically, I
remember contributions by Paul Johnson ("rockchalk" package) and John Fox
("effects" and "car" package) as their packages