Displaying 20 results from an estimated 24 matches for "age1".
Did you mean:
age
2007 Nov 02
3
writing a categorical var. with condition
Hello,
I want to create a new variable which includes 4 age categories in this way:
if (age>=12 && age<32) age1==1
if (age>=32 && age<52) age1==2
if (age>=52 && age<72) age1==3
if (age>=72 && age<100) age1==4
but I get the results only for the first observation.
how can I apply this condition to all observations?
Thanks in advance,
Sigalit.
[[alternative HTM...
2008 Jan 15
2
Looking for simpler solution to probabilistic question
Hi
I have two processes which take with a certain probability (p1 and p2) x
number of years to complete (age1 and age2). As soon as thge first
process is completed, the second one begins. I want to calculate the
time it takes for the both processes to be completed.
I have the following script which gives me the answer, butI think there
must be a more elegant way of doing the calculations between the ##...
2007 Feb 09
2
LM Model
Dear R-Users,
How can I put a pre-defined regression model into to an object of class lm
in order to use the predict.lm function.
A simplified example:
I would normally run a regression analysis on a dataset,
> germany<-lm(RENT~AGE1, in.mi01)
> summary(germany)
Call:
lm(formula = RENT ~ AGE1, data = in.mi01)
Residuals:
Min 1Q Median 3Q Max
-12.193 -3.646 -1.009 2.101 49.025
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 13.283639 0.063020 210...
2002 Nov 26
1
Reshape by multiple variables
Dear list
I'm using the reshape command and want to reshape a wide data set to a
long one
e.g. I have the variables y1,y2,y3,age1,age2,age3,sex,ethnic
I want my new long data set to consist of the variables y (which has
been created from y1,y2,y3), age (which has been created from
age1,age2,age3), sex and ethnic
I have tried to use the command:
data1<-reshape(data,varying=list(c("y1","y2","y3&qu...
2009 Sep 21
2
cox memory
Hi there,
I have a rather large data set and perform the following cox model:
test1 <- list(tstart,tstop,death1,chemo1,radio1,horm1)
out1<-coxph( Surv(tstart,tstop, death1) ~ chemo1+chemo1:log(tstop+1)+horm1+horm1:log(tstop+1)+age1+grade1+grade1:log(tstop+1)+positive1+positive1:log(tstop+1)+size1+size1:log(tstop+1), test1)
out1
Up to here everything works fine (with each covariate having a length of 289205)
Now I want to see a specific profile of the above model so I ask for:
x11()
profilbig2=(survfit(out1,newdata=data.fra...
2008 Nov 06
3
unlist & dataframes
...4],Age=3:4)
l=list(x1,x2)
l
[[1]]
Name Age
1 A 1
2 B 2
[[2]]
Name Age
1 C 3
2 D 4
I would like to unlist l to create a dataframe with 2 columns and 4 rows but
keeping the format of Name (character) and Age (numeric).
Now when I unlist l, I obtain :
unlist(l)
Name1 Name2 Age1 Age2 Name1 Name2 Age1 Age2
1 2 1 2 1 2 3 4
Is there a way to at least obtain something like
A 1 B 2 C 3 D 4 as result from the unlist??
Thanks a lot for your replies
Naira
--
View this message in context: http://www.nabble.com/unlist---dataframes-tp20358993p2...
2008 May 12
1
Standard error of combination of parameter estimates
Hi,
Is there a simple command for computing the standard error of a
combination of parameter estimates in a GLM?
For example:
riskdata$age1 <- riskdata$age
riskdata$age2 <- ifelse(riskdata$age<67,0,riskdata$age-67)
model <- glm(death~age1+age2+ldl,
data=riskdata,family=binomial(link=logit))
And we want to find the standard error of the partial linear predictor
for the combination of the two age parameters, age1+age...
2005 Aug 12
2
coercing created variables into a new data frame using na.omit()
...en using
na.omit(). To illustrate this problem I will give the example I am working on
and the approah I have been using:-
data.frame1<-filepath....
attach(data.frame1)
#create a new variable using a function
new.variable<-rep(1,length(weight3))
for (x in 1:length(new.variable))
{f<-((((age1[x]-7)*(weight[x]-mw))+((age2[x]-7)*(weight2[x]-mw))+((age3[x]-7)*
(weight3[x]-mw)))/(((age1[x]-7)^2)+((age2[x]-7)^2)+((age3[x]-7)^2)));
new.variable[x]<-f}
#then bind it into the existing old data frame
data.frame2<-cbind(data.frame1,newvariable)
rm(dat.frame1)
attach(data.frame2)
#everythin...
2007 Mar 05
1
Matrix/dataframe indexing
Hi all,
I am hoping someone can help me out with this:
If I have dataframe of years and ages and the first column and first row
are filled with leading values:
Df<- age1 age2 age3
Yr1 1 0.4 0.16
Yr2 1.5 0 0
Yr3 0.9 0 0
Yr4 1 0 0
Yr5 1.2 0 0
Yr6 1.4 0 0
Yr7 0.8 0 0
Yr8 0.6 0 0
Yr9 1.1 0 0
Now the rest of the cells need to be filled according to the previous
year and age cell so arbitrarily, cell [2,2] should be value in cell
[1,1] * exp(0.3), and c...
2007 Feb 09
1
subset function
Hello R-Users,
I have the following problem with the subset function:
See the following simple linear model. Here everything works fine:
>germany<-lm(RENT~AGE1, in.mi01)
However, if a use the same regression equation and only specify a subset, I
get an error message:
> berlin<-lm(RENT~AGE1, in.mi01, subset=C_X01=="Berlin")
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
T...
2011 Oct 05
1
calling a variable which in turn calls many more variables
...running regressions with many covariates, most of which remain the same
each time (control variables). Instead of writing 30 demographic variables
every regression, is there a way I could call them all at once using a
variable called, perhaps "demog"?
I have tried:
> demog <- list(age1, age2, age3) but I get an error when I try to call a
list in a regression.
I also tried:
> demog <- cbind(age1, age2, age3) which allows me to run a regression, but
this is not practical because when I subset the original data set and run a
regression, this new matrix demog doesn't get s...
2003 Dec 17
5
beginner programming question
...I have a (rather theoretical) programming problem for which I have found
a solution, but I feel it is a rather poor one. I wonder if there's some
other (more clever) solution, using (maybe?) vectorization or
subscripting.
A toy example would be:
rel1 rel2 rel3 age0 age1 age2 age3
sex0 sex1 sex2 sex3
1 3 NA 25 23 2 NA
1 2 1 NA
4 1 3 35 67 34 10
2 2 1 2
1 4 4 39...
2008 Jun 05
1
quite complicated case(the repeated data arranage~)
...40,30,11,23,24,56,65,60)
id<-c(1,1,3,4,4,6,8,9,9)
table1<-cbind(treatment,id,age,y)
*the actual data are way more than this*,the id is from 1~500,and not in
regular ,some number missing~
all I want to do is
put the cases to variable according the id
for example when id =1
we have
treatment1 age1 y
low 50 20
high 60 40
this will generate a new matrix
for this example I will have 6 new matrix,according to id.
it is reasonable to do this in loop for,but the I met some problem:
1:how to automatically generate the new title such as treatment1 and age1
until tr...
2010 Sep 12
3
reshape matrix entities to columns
Greeting R helpers J
I am not familiar with R but I have to use it to analyze data set that I have
(30,000 20,000)
I want to change the structure of the dataset and I am wondering how that might
be possible in R
A main data looks like this: some entities are empty
Age No. Age No. Age No.
Center1 5 2 8
7
2012 Jul 31
1
Mediation analysis
...Preacher's Bootstrapping test for mediation (Preacher & Hayes, 2004). I have
attempted to use the mediate package to set this up, using code that looks
basically like this:
model.m <- lm(data$outcome ~ data$mediator + desirdata$predictor)
model.y <- lm(data$outcome ~ data$predictor)
age1 <- mediate(model.m, model.y, treat = "predictor", mediator =
"mediator", conf.level=.95, boot=TRUE, sims=50)
However, I get an error indicating that the number of observations doesn't
match across the two models. This may be true, because it's a somewhat
large samp...
2018 Feb 16
0
analysis of covariance and constrained parameters
...between value and Cohort could be
glm(value ~ Age/Cohort -? 1, family =......, data = .....)
glm(value ~ Age/(Cohort + I(Cohort^2)) - 1, family =......, data = .....).
The latter commands would provide estimates of the age-specific
intercept, linear, and quadratic coefficients, as in
value_Age1 <- intercept_Age1 + linear_Age1*Cohort + quad_Age1*Cohort^2
value_Age2 <- intercept_Age2 + linear_Age2*Cohort + quad_Age2*Cohort^2
This is standard. One would choose among the above models via analysis
of variance or AIC.
Now assume that I have external knowledge that tells me that ther...
2007 May 05
1
importing data
...rt manual.
It is a bit peculiar because my data base is already an R object called "japan".
I guess it is not yet a data set, and I don't know how to manipulate variables from it.
When I type "japan", here is an extract of what I get.
LDP NFP SKG JCP gender education age1 80 75 80 0 male 1 752 75 80 50 20 female 1 643 100 25 100 0 male 2 564 75 50 25 50 male 2 525 75 50 50 0 male 4 52
I have saved the following objet in a file called "japan.RData". Then I have tried the fol...
2008 Aug 21
1
Interpreting Logistic Regression
...f Binomial? How will it affect my results?
(b) How do I interpret the "R" result as given below? I know all the variables are significant. How do I get Log Likelihood ratio, Odds ratio etc.?
Please can anyone help me out.
With warm regards
Madhavi
R OUTPUT
Call:
glm(formula = Y ~ Age1 + Age2 + Sex + Education + Profession + SavingsAccount +
CurrentAccount, family = binomial(link = logit), data = ons)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.21142 -0.42556 -0.15911 -0.02954 3.02465
Coefficients:
Estimate Std. Error...
2008 Aug 20
1
Understanding output of summary(glm(...))
...899 10.025943 [8] 9.971243 10.177766 9.265793 9.415818 10.099874 10.238829 9.575591[15] 9.560879 9.617891 9.617891 10.158160 10.592377 10.068443
>summary(glm(tmp1 ~ -1 + age, data=data.frame(as.vector(as.matrix(tmp1)), age)))$coefficients Estimate Std. Error t value Pr(>|t|)age1 9.541423 0.1611603 59.20456 3.380085e-19age2 10.083694 0.1611603 62.56935 1.479781e-19age3 9.739813 0.1611603 60.43557 2.485380e-19age4 9.748297 0.1611603 60.48821 2.453251e-19age5 10.109218 0.1611603 62.72773 1.424913e-19
m1 <- data.frame(tmp1, gp)
>sapply(age, function(x) sd(m1[m1...
2010 Feb 11
1
Rounding multinomial proportions
...version of it, to the 'stats' package,
with the other multinomial functions reside.
I'm using R to export data to text files, which are input data for an
external model written in C++. Parts of the data are age distributions, in
the form of relative frequency in each year:
Year Age1 Age2 ... Age10
1980 0.123 0.234 ... 0.001
... ... ... ... ...
Each row should sum to exactly 1. The problem is that when I preprocess
each line in R as p<-a/sum(a), occasionally a line will sum to 0.999,
1.002, or the like. This could either crash the external model or...