Displaying 20 results from an estimated 20000 matches similar to: "A Tip: lm, glm, and retained cases"
2008 Mar 12
1
[follow-up] "Longitudinal" with binary covariates and outcome
Hi again!
Following up my previous posting below (to which no response
as yet), I have located a report which situates this type
of question in a longitudinal modelling context.
http://www4.stat.ncsu.edu/~dzhang2/paper/glm.ps
Generalized Linear Models with Longitudinal Covariates
Daowen Zhang & Xihong Lin
(This work seems to originally date from around 1999).
They consider an outcome Y,
2008 Mar 29
1
Tabulating Sparse Contingency Table
I have a sparse contingency table (most cells are 0):
> xtabs(~.,data[,idx:(idx+4)])
, , x3 = 1, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 31
2 0 0 112
3 0 0 94
, , x3 = 2, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 3, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 1, x4
2006 Oct 06
1
Sum of Bernoullis with varying probabilities
Hi Folks,
Given a series of n independent Bernoulli trials with
outcomes Yi (i=1...n) and Prob[Yi = 1] = Pi, I want
P = Prob[sum(Yi) = r] (r = 0,1,...,n)
I can certainly find a way to do it:
Let p be the vector c(P1,P2,...,Pn).
The cases r=0 and r=n are trivial (and also are exceptions
for the following routine).
For a given value of r in (1:(n-1)),
library(combinat)
Set <- (1:n)
2005 Jun 09
1
Prediction in Cox Proportional-Hazard Regression
He,
I used the "coxph" function, with four covariates.
Let's say something like that
> model.1 <- coxph(Surv(Time,Event)~X1+X2+X3+X4,data=DATA)
So I obtain the 4 coefficients B1,B2,B3,B4 such that
h(t) = h0(t) exp(B1*X1+ B2*X2 + B3*X3 + B4*X4).
When I use the function on the same data
> predict.coxph(model.1,type="lp")
how it works in making the prediction?
2012 Oct 20
2
Help with programming a tricky algorithm
Hi All,
I'm a little stumped by the following problem. I've got a dataset with
the following structure:
idxy ix iy country (other variables)
1 1 1 c1 x1
2 1 2 c1 x2
3 1 3 c1 x3
. . . . .
3739 55 67 c7 x3739
3740 55 68 c7 x3740
where ix and
2012 May 01
3
Data frame vs matrix quirk: Hinky error message?
AdvisoRs:
Is the following a bug, feature, hinky error message, or dumb Bert?
> mtest <- matrix(1:12,nr=4)
> dftest <- data.frame(mtest)
> ix <- cbind(1:2,2:3)
> mtest[ix] <- NA
> mtest
[,1] [,2] [,3]
[1,] 1 NA 9
[2,] 2 6 NA
[3,] 3 7 11
[4,] 4 8 12
## But ...
> dftest[ix] <- NA
Error in `[<-.data.frame`(`*tmp*`, ix, value
2002 Dec 20
1
Printing correlation matrices (lm/glm)
Hi Folks,
I'm analysing some data which, in its simplest aspect,
has 3 factors A, B, C each at 2 levels.
If I do
lm1 <- lm(y ~ A*B)
say, and then
summary(lm1, corr=T)
I get the correlation matrix of the estimated coeffcients
with numerical values for the correlations (3 coeffs in this
case). Likewise with 'glm' instead of 'lm'.
However, if I do
lm2 <- lm(y ~
2011 Jul 29
2
'breackpoints' (package 'strucchange'): 2 blocking error messages when using for multiple regression model testing
Good morning to all,
I am encountering a blocking issue when using the function 'breackpoints'
from package 'strucchange'.
*Context:*
I use a data frame, 248 observations of 5 variables, no NA.
I compute a linear model, as y~x1+...+x4
x4 is a dummy variable (0 or 1).
I want to check this model for structural changes.
*Process & issues:*
*First, I used function Fstats.* It
2012 Sep 01
1
Vectorial analogue of all.equal()?
Greetings All.
Once again, I am probably missing something fairly accessible,
but since I can't find it I'd welcome advice!
I have a dataframe derived from a text file of data in tabular
format. For one of the variables, say X, I want to select the
subsets which in which X equals a particular value.
Such values are given in the text file like: 2.3978953, and each
such value will occurr
2012 Oct 23
0
lm and glm
Dear list,
I am making a linear regression of the following format.
lm(Y~X1+X2+log(X3)+log(X4))
Now I would like to check the linear regression above using generalized
linear model.
Please kindly if the following format is correct and thank you.
(If it is wrong, please indicate why.)
glm(Y~X1+X2+log(X3)+log(X4), family=poisson(link="log"))
Also, please kindly suggest any references
2008 May 13
1
Missing coefficient on a glm object
Hello guys, i looked over the archive files and found nothing about this
kind of error.
I have a database of 33 elements described in 8 variables, i'm using the
Leave-One-Out iterative process
to take one of the elements to be the test element and make a regression
with the other 32 and then
I try to predict the clas of the element out.
I'm using this call as a part of a Leave-One-Out
2011 Apr 21
1
Converting from density to cumulative distribution
Hello
I'm trying to do the following vector operation:
given vector x = c(x1,x2,x3,x4...xn), produce vector y =
c(x1,x1+x2,x1+x2+x3,...x1+...+xn).
E.g., from x = c(1,3,2,2,5), produce y = c(1,4,6,8,13).
The underlying problem is finding the cumulative distribution function
given the empirical density distribution function.
I have done some research on this but the only relevant
2006 Mar 11
1
Non-linear Regression : Error in eval(expr, envir, enclos)
Hi..
i have an expression of the form:
model1<-nls(y~beta1*(x1+(k1*x2)+(k1*k1*x3)+(k2*x4)+(k2*k1*x5)+(k2*k2*x6)+(k3*x7)+(k3*k4*x8)+(k3*k2*x9)+(k3*k3*x10)+ (k4*x11)+(k4*k1*x12)+(k4*k2*x13)+(k4*k3*x14)+(k4*k4*x15)+(k5*x16)+(k5*k1*x17)+(k5*k2*x18)+(k5*k3*x19)+
2007 Jul 20
1
cv.glm error function
I have a couple quick questions about the use of cv.glm for
cross-validation.
1. If we have a Poisson GLM with counts Y~Poisson(mu) and
ln(mu)=beta0+beta1*x1+..., is the prediction error (delta) that is output
from cv.glm provided in terms of the counts (y) or the (mu)?
2. Can cv.glm be used for negative binomial models fit using glm.nb? It
appears to work, but since NB models aren't
2005 Oct 05
1
Ad: Re: R crashes for large formulas in lm() (PR#8180)
Dette er en melding med flere deler i MIME-format.
--=_alternative 004613C000257091_=
Content-Type: text/plain; charset="US-ASCII"
And some more informastion I forgot.
R does not crash if I write out the formula:
set.seed(123)
x1 <- runif(1000)
x2 <- runif(1000)
x3 <- runif(1000)
x4 <- runif(1000)
x5 <- runif(1000)
x6 <- runif(1000)
x7 <- runif(1000)
x8 <-
2013 Apr 13
1
how to add a row vector in a dataframe
Hi,
Using S=1000
and
simdata <- replicate(S, generate(3000))
#If you want both "m1" and "m0" #here the missing values are 0
res1<-sapply(seq_len(ncol(simdata.psm1)),function(i) {x1<-merge(simdata.psm0[,i],simdata.psm1[,i],all=TRUE); x1[is.na(x1)]<-0; x1})
res1[,997:1000]
#????? [,1]???????? [,2]???????? [,3]???????? [,4]???????
#x1??? Numeric,3000 Numeric,3000
2009 Nov 29
4
lm() notation question
Hi,
A recent thread provided a (working) construct for lm:
lm(as.matrix(freeny[ix]) ~., freeny[-ix])
Can someone explain what is meant by the formula in that expression,
that is, what does "mymatrix~." do? I couldn't find any such example
in the lm() or formula() help pages.
thanks
Carl
2006 Aug 29
0
how to contrast with factorial experiment
Hello, R experts,
If I understand Ted's anwser correctly, then I can not contrast the
mean yields between sections 1-8 and 9-11 under "Trt" but I can
contrast mean yields for sections 1-3 and 6-11 because there exists
significant interaction between two factors (Trt:section4,
Trt:section5). Could I use the commands below to test
the difference between sections 1-3 and 6-11 ?
2006 Jan 29
1
extracting 'Z' value from a glm result
Hello R users
I like to extract z values for x1 and x2. I know how to extract coefficents
using model$coef
but I don't know how to extract z values for each of independent variable. I
looked around
using names(model) but I couldn't find how to extract z values.
Any help would be appreciated.
Thanks
TM
#########################################################
>summary(model)
Call:
2004 Nov 08
1
plotting lm coeficients with their means
I am trying to write a function that will run a linear
model and plot the regression coeficients with their
corresponding means. I am having two problems. I can
get the plot with the function below, but I am having
trouble labeling the points.
function(y,x1,x2,x3,x4){
outlm<-lm(y~x1+x2+x3+x4)
imp<-as.data.frame(outlm$coef[-1])
meanvec<-c(mean(x1),mean(x2),mean(x3),mean(x4))