similar to: How to find the interception point of two linear fitted model in R?

Displaying 20 results from an estimated 2000 matches similar to: "How to find the interception point of two linear fitted model in R?"

2010 Jan 28
2
Data.frame manipulation
Hi All, I'm conducting a meta-analysis and have taken a data.frame with multiple rows per study (for each effect size) and performed a weighted average of effect size for each study. This results in a reduced # of rows. I am particularly interested in simply reducing the additional variables in the data.frame to the first row of the corresponding id variable. For example:
2010 Feb 15
2
creating functions question
Hi All, I am interested in creating a function that will take x number of lm objects and automate the comparison of each model (using anova). Here is a simple example (the actual function will involve more than what Im presenting but is irrelevant for the example): # sample data: id<-rep(1:20) n<-c(10,20,13,22,28,12,12,36,19,12,36,75,33,121,37,14,40,16,14,20)
2011 Oct 26
2
Error in summary.mlm: formula not subsettable
When I fit a multivariate linear model, and the formula is defined outside the call to lm(), the method summary.mlm() fails. This works well: > y <- matrix(rnorm(20),nrow=10) > x <- matrix(rnorm(10)) > mod1 <- lm(y~x) > summary(mod1) ... But this does not: > f <- y~x > mod2 <- lm(f) > summary(mod2) Error en object$call$formula[[2L]] <- object$terms[[2L]]
2010 Jul 09
1
output without quotes
Hi All, I am interested in printing column names without quotes and am struggling to do it properly. The tough part is that I am interested in using these column names for a function within a function (e.g., lm() within a wrapper function). Therefore, cat() doesnt seem appropriate and print() is not what I need. Ideas? # sample data mod1 <- rnorm(20, 10, 2) mod2 <- rnorm(20, 5, 1) dat
2013 Nov 25
4
lmer specification for random effects: contradictory reults
Hi All, I was wondering if someone could help me to solve this issue with lmer. In order to understand the best mixed effects model to fit my data, I compared the following options according to the procedures specified in many papers (i.e. Baayen <http://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CDsQFjAA
2012 Jun 06
3
Sobel's test for mediation and lme4/nlme
Hello, Any advice or pointers for implementing Sobel's test for mediation in 2-level model setting? For fitting the hierarchical models, I am using "lme4" but could also revert to "nlme" since it is a relatively simple varying intercept model and they yield identical estimates. I apologize for this is an R question with an embedded statistical question. I noticed that a
2008 Oct 16
1
lmer for two models followed by anova to compare the two models
Dear Colleagues, I run this model: mod1 <- lmer(x~category+subcomp+category*subcomp+(1|id),data=impchiefsrm) obtain this summary result: Linear mixed-effects model fit by REML Formula: x ~ category + subcomp + category * subcomp + (1 | id) Data: impchiefsrm AIC BIC logLik MLdeviance REMLdeviance 4102 4670 -1954 3665 3908 Random effects: Groups Name Variance
2003 Feb 10
2
problems using lqs()
Dear List-members, I found a strange behaviour in the lqs function. Suppose I have the following data: y <- c(7.6, 7.7, 4.3, 5.9, 5.0, 6.5, 8.3, 8.2, 13.2, 12.6, 10.4, 10.8, 13.1, 12.3, 10.4, 10.5, 7.7, 9.5, 12.0, 12.6, 13.6, 14.1, 13.5, 11.5, 12.0, 13.0, 14.1, 15.1) x1 <- c(8.2, 7.6,, 4.6, 4.3, 5.9, 5.0, 6.5, 8.3, 10.1, 13.2, 12.6, 10.4, 10.8, 13.1, 13.3, 10.4, 10.5, 7.7, 10.0, 12.0,
2010 Feb 20
3
aggregating using 'with' function
Hi All, I am interested in aggregating a data frame based on 2 categories--mean effect size (r) for each 'id's' 'mod1'. The 'with' function works well when aggregating on one category (e.g., based on 'id' below) but doesnt work if I try 2 categories. How can this be accomplished? # sample data id<-c(1,1,1,rep(4:12)) n<-c(10,20,13,22,28,12,12,36,19,12,
2006 Aug 29
2
lattice and several groups
Dear R-list, I would like to use the lattice library to show several groups on the same graph. Here's my example : ## the data f1 <- factor(c("mod1","mod2","mod3"),levels=c("mod1","mod2","mod3")) f1 <- rep(f1,3) f2 <-
2008 Sep 08
1
correct lme syntax for this problem?
Hello all, I am about to send off a manuscript and, although I am fairly confident I have used the lme function correctly, I want to be 100% sure. Could some kind soul out there put my mind at ease? I am simply interested in whether a predictor (SPI) is related to height. However, there are five different populations, and each may differ in mean level of height as well as the relationship
2011 Jul 22
1
how to fix coefficients in regression
Hello all, I am using a glm() and would like to fix one of the regression coefficients to be a particular value and see what happens to the fit of the model. E.g.: mod1 <- glm(Y ~ X1 + X2,family='binomial') mod2 <- glm(Y~[fixed to 1.3]X1 + X2,family='binomial') The beta for X1 is freely estimated in mod1 but is constrained to be 1.3 in mod2. Is there a way to do this?
2006 Jul 21
1
Parameterization puzzle
Consider the following example (based on an example in Pat Altham's GLM notes) pyears <- scan() 18793 52407 10673 43248 5710 28612 2585 12663 1462 5317 deaths <- scan() 2 32 12 104 28 206 28 186 31 102 Smoke <- gl(2,1,10,labels=c("No","Yes")) Age <- gl(5,2,10,labels=c("35-44","45-54","55-64","65-74","75-84"),
2009 Sep 05
8
Color index in image function
Dear All, I was looking for the color index in?image function,?such as from topo.colors(n) and etc. but still never found it. For instance, from the help menu. ########################################### # Volcano data visualized as matrix. Need to transpose and flip # matrix horizontally. image(t(volcano)[ncol(volcano):1,]) # A prettier display of the volcano x <- 10*(1:nrow(volcano)) y
2011 Apr 08
1
Variance of random effects: survreg()
I have the following questions about the variance of the random effects in the survreg() function in the survival package: 1) How can I extract the variance of the random effects after fitting a model? For example: set.seed(1007) x <- runif(100) m <- rnorm(10, mean = 1, sd =2) mu <- rep(m, rep(10,10)) test1 <- data.frame(Time = qsurvreg(x, mean = mu, scale= 0.5, distribution =
2008 Oct 22
1
lme4 question
Dear R Colleagues, I run the following two models: mod1 <- lmer(y ~ category + subcomp + (1 | id)) mod2 <- lmer(y ~ category + subcomp + category*subcomp + (1 | id) where: category has 4 possible values subcomp has 24 possible values id has approx 120 values (id is nested within category, and in unequal numbers--i.e., unbalanced) Then to look for differences in the models I run:
2009 Apr 03
1
Trouble extracting graphic results from a bootstrap
Hi, I'm trying to extract a histogram over the results from a bootstrap. However I keep receiving the error message "Error in hist.default(boot.lrtest$ll, breaks = "scott") : 'x' must be numeric". The bootstrap I'm running looks like: > boot.test <- function(data, indeces, maxit=20) { + y1 <- fit1+e1[indeces] + mod1 <- glm(y1 ~ X1-1, maxit=maxit) +
2010 Aug 03
1
"glmulti": defining which intractions between variables are to be included
Hello, I'm using the "glmulti" package to run models of all the possible combinations of my variables. However, I am only interested in a few interactions between my variables. I have tried the equivalent of: mod1<-lm(y~a+b+c+a:b) glmulti(mod1, level=1) mod2<-lm(y~a+b+c+a:b) glmulti(mod2, level=2) and glmulti("y", c("a", "b", "c"),
2009 Sep 23
4
Problem in graph plotting
Dear All, Let: dp: depth of the?river tp: temperature with respect to depth We can?have a simple scatter plot, between depth as y-axis and temperature as x-axis,?by using a?plot function as shown?below. #####################? dp <- c(1,4,3,2,5,7,9,8,9,2) tp <- 1:10 plot(tp,dp, type= 'l') ##################### ? Could someone advice me on?the way to?plot the same pair of
2010 Feb 17
1
Replicating output from a function
Hi All, I have a function that is used with data frames having multiple id's per row and it aggregates the data down to 1 id per row. It also randomly selects one of the within-id values of a variable (mod), which often differ within-id. Assume this data frame (below) is much larger and I want to repeat this function, say 100 times, and then derive the mean values of r over those 100