Re: [R] String substitution

2013-10-04 Thread irene
Wonderful!

Thank you Arun!

Irene
 
Irene Ruberto





 Da: arun kirshna [via R] ml-node+s789695n4677558...@n4.nabble.com

Inviato: Giovedì 3 Ottobre 2013 22:51
Oggetto: Re: String substitution



Hi, 
Try: 
dat$y- as.character(dat$y) 
dat1- dat 
dat2- dat 
library(stringr) 
 dat$y[NET]- substr(word(dat$y[NET],2),1,1) 
 dat$y 
#[1] n     n     house n     tree 

#or 
for(i in 1:length(NET)){dat1$y[NET[i]]- n} 
 dat1$y 
#[1] n     n     house n     tree 
#or 
dat2$y[NET]- gsub(.*(n).*,\\1,dat2$y[NET]) 
 dat2$y 
#[1] n     n     house n     tree 


A.K. 


Hello, 

I am trying to replace strings containing a certain word, I 
first identified the word (in this example net) with grep, and then I 
need to replace those string with n. It should be very simple but I 
don't seem to find the solution. 
  
Example: 

x-c(5:9) 
y- c(with net, with nets, house, no nets, tree) 
dat-as.data.frame(cbind(x, y) ) 
NET-grep(net, dat$y) 

# I want y to become (n, n, house, n, tree) # 

# I have tried several ways including the following but without success # 

for (i in 1: length(NET)) { 
dat$y[NET[i]]- n } 


Thank you for your help! 

__ 
[hidden email] mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code. 




If you reply to this email, your message will be added to the discussion 
below:http://r.789695.n4.nabble.com/String-substitution-tp4677541p4677558.html 
To unsubscribe from String substitution, click here.
NAML



--
View this message in context: 
http://r.789695.n4.nabble.com/String-substitution-tp4677541p4677612.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] help: R GUI front-end has stopped working

2013-05-13 Thread irene castro conde
Hello,

I'm using the function nlminb of the package stats inside a loop and when the 
number of trials grows, R crashes and says R 
GUI front-end has stopped working. Could you help me with this problem? I have 
try in versions 2.15.1,2.15.2 and 3.0.0.  

 sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Galician_Spain.1252  LC_CTYPE=Galician_Spain.1252   
[3] LC_MONETARY=Galician_Spain.1252 LC_NUMERIC=C   
[5] LC_TIME=Galician_Spain.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 


This is my code:



u-runif(3000)

k=13

n=length(u)

prob=vector(length=n)

ro=vector(length=n)

beta1=vector(length=n)

g1=vector(length=n)

sb1=vector(length=n)

low=vector(length=n)

tlow=vector(length=n)

effects=vector(length=n)

vb1=vector(length=n)

AA=list()

BB=list()

nnI=list()

library(stats)

for (i in 1:n){

v=as.numeric(u=u[i])

p=mean(v)

A=vector(length=k)

n1=n%/%k

A-sapply(1:k,function(m) A-sum(v[((m-1)*n1+1):(m*n1)]))

A[k]=sum(v[((k-1)*n1+1):n])

AA[[i]]-A

B=c(rep(n1,k-1),length(v[((k-1)*n1+1):n]))

BB[[i]]-B

l1=vector(length=(length(A)))

L1-function(pe,rho){

for(j in 1:length(A)){

if(A[j]==0){l1[j]=0} else {l1[j]-sum(log(pe+(-rho/(rho-1))*(0:(A[j]-1}

}

return(sum(l1))}

l2=vector(length=(length(B-A)))

L2-function(pe,rho){

for(j in 1:length(B-A)){

if((B[j]-A[j])==0){l2[j]=0} else 
{l2[j]-sum(log(1-pe+(-rho/(rho-1))*(0:(B[j]-A[j]-1}

}

return(sum(l2))}

l3=vector(length=(length(B)))

L3-function(pe,rho){

for(j in 1:length(A)){

if(B[j]==0){l1[j]=0} else {l3[j]-sum(log(1+(-rho/(rho-1))*(0:(B[j]-1}

}

return(sum(l3))}

L-function(pe,rho){

L-L1(pe,rho)+L2(pe,rho)-L3(pe,rho)

return(L)

}

Max- function(x){ -L(x[1], x[2])}


opt-nlminb(c(0.01,0.01), Max,lower = rep(0.001,2), upper = 
rep(0.999,2),control=list(rel.tol=1e-6))
prob[i]=opt$par[1]

ro[i]=opt$par[2]

}


Thanks,
Irene Castro Conde.   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] long margin text below lattice plot - how to wrap lines?

2012-12-11 Thread Irene Prix
Thanks a million!

 - Original Message -
 From: Pascal Oettli
 Sent: 12/12/12 09:37 AM
 To: knallg...@gmx.com
 Subject: Re: [R] long margin text below lattice plot - how to wrap lines?
 
 Hello
 
 You can insert \n in your text.
 
 mytext - textGrob(This is such a very very long text\n that it goes on 
 forever and therefore needs to be wrapped in order\n for someone to be 
 able to read it properly.)
 
 HTH
 Pascal
 
 
 Le 12/12/2012 16:22, knallg...@gmx.com a écrit :
  Hello,
 
  I've got a lattice plot and need to add text into the bottom margin of the 
  plotting area (below the bottom legend).
  This seems to work in principle using grid.arrange, yet the text to be 
  added is rather long. As a consequence, it gets clipped:
 
  require(lattice)
  require(grid)
  myplot - xyplot(1~1)
  mytext - textGrob(This is such a very very long text that it goes on 
  forever and therefore needs to be wrapped in order for someone to be able 
  to read it properly.)
  grid.arrange(myplot, sub=mytext)
 
  Is there any way to wrap the lines of the text or some other of workaround 
  to this problem?
 
  I've tried figuring it out myself, but it's a rather urgent problem and 
  therefore I was hoping to find some help here.
 
  Best,
  Irene
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] match and substitute two variables

2012-12-03 Thread irene
Hello, 
I have two variables (of different length and from two different data
frames):

code- c(101001,  1032, 102, 101001, 102, 1032);
name- c(101001 Alta, 102 Bassa, 1032 Media);

and I would like to substitute the first variable with the  second variable
according to their shared numerical part, thus obtaining the following
result:

code.new
101001 Alta  1032 Media 102 Bassa101001 Alta 102 Bassa 1032
Media

I tried using: - sapply(code, gsub, pattern=\\d+, replacement=name) but
the replacement cannot be of length more than one, thus my output is only
101001 Alta 101001 Alta... I am not sure how to get the right answer...

Thank you!



--
View this message in context: 
http://r.789695.n4.nabble.com/match-and-substitute-two-variables-tp4651893.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] match and substitute two variables

2012-12-03 Thread irene
It works perfectly, thank you!



--
View this message in context: 
http://r.789695.n4.nabble.com/match-and-substitute-two-variables-tp4651893p4651906.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Extracting week number starting from a specific date

2012-04-30 Thread irene
Hello,

I have a list of dates, such as

dates- as.Date(c(1996-03-29,1996-05-30,1996-09-28,1996-05-09))

from which I would like to extract the week number for each date, with week
n°1 being the week going from Dec 30th 1995 to Jan 6th 1996 (1995-30-12 to
1996-06-01). Any suggestion for a simple way to do that?

Thank you

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-week-number-starting-from-a-specific-date-tp4598676.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extracting numbers from a character variable of different types

2012-03-26 Thread irene
It worked perfectly!

Thank you

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4505914.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Extracting numbers from a character variable of different types

2012-03-18 Thread irene
Hello,

I have a file which contains a column with age, which is represented in the
two following patterns

1. 007/A or ''007/a or ''7 /a . In this case A or a means year and I
would like to extract only the numeric values eg 7 in the above case if this
pattern exits in a line of file.

2. 004/M or 004/m where M or m means month .. for these lines I
would like to first extract the numeric value of Month eg. 4  and then
convert it into a value of years, which would be 0.33 eg 4 divided by 12.

Can anyone help?

Thank you 

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4482248.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] color of error bars in Dotplot (Hmisc)

2011-07-27 Thread Irene Prix
Hello!

In a grouped Dotplot, is there any way to set the color of error bars
to be the same as the corresponding symbols?


Example data:

require(lattice)
require(Hmisc)
data(barley)

Dotplot(variety~Cbind(yield, yield+2, yield-2)|year, groups=site,
data=barley)


I experimented with changing trellis settings of plot.line (as
mentioned in the Hmisc documentation) as well as col.line settings in
simpleTheme, but that didn't work. Changing the error bars to any
one other color does work, but I can't seem to figure out how to set
them to the color of each group-specific symbol...

I'd be grateful for any advice,

Irene

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fitting gamm with interaction term

2011-03-17 Thread Irene Mantzouni
Hi all,

 

I would like to fit a gamm model of the form:

 

Y~X+X*f(z)

Where f is the smooth function and 

With random effects on X and on the intercept.

 

So, I try to write it like this:

 

gam.lme- gamm(Y~ s(z, by=X) +X,  random=list(groups=pdDiag(~1+X))  )

 

but I get the error message :

 

Error in MEestimate(lmeSt, grps) : 

  Singularity in backsolve at level 0, block 1

 

When I simply fit a gam model using the formula above, then it works ok.

 

Is it possible to fit such a model with gamm?

 

 

Thanks a lot!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fitting gamm with interaction term

2011-03-17 Thread Irene Mantzouni
Hi all,

 

I would like to fit a gamm model of the form:

 

Y~X+X*f(z)

Where f is the smooth function and 

With random effects on X and on the intercept.

 

So, I try to write it like this:

 

gam.lme- gamm(Y~ s(z, by=X) +X,  random=list(groups=pdDiag(~1+X))  )

 

but I get the error message :

 

Error in MEestimate(lmeSt, grps) : 

  Singularity in backsolve at level 0, block 1

 

When I simply fit a gam model using the formula above, then it works ok.

 

Is it possible to fit such a model with gamm?

 

 

Thanks a lot!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Conditional editing of rows in a data frame

2010-01-28 Thread Irene Gallego Romero
Dear R users,

I have a dataframe (main.table) with ~30,000 rows and 6 columns, of
which here are a few rows:

  id chr window gene xp.normxp.top
129 1_32   1 32   TAS1R1  1.28882115 FALSE
130 1_32   1 32   ZBTB48  1.28882115 FALSE
131 1_32   1 32   KLHL21  1.28882115 FALSE
132 1_32   1 32PHF13  1.28882115 FALSE
133 1_33   1 33PHF13  1.02727430 FALSE
134 1_33   1 33THAP3  1.02727430 FALSE
135 1_33   1 33  DNAJC11  1.02727430 FALSE
136 1_33   1 33   CAMTA1  1.02727430 FALSE
137 1_34   1 34   CAMTA1  1.40312732  TRUE
138 1_35   1 35   CAMTA1  1.52104538 FALSE
139 1_36   1 36   CAMTA1  1.04853732 FALSE
140 1_37   1 37   CAMTA1  0.64794094 FALSE
141 1_38   1 38   CAMTA1  1.23026086  TRUE
142 1_38   1 38VAMP3  1.23026086  TRUE
143 1_38   1 38 PER3  1.23026086  TRUE
144 1_39   1 39 PER3  1.18154967  TRUE
145 1_39   1 39 UTS2  1.18154967  TRUE
146 1_39   1 39  TNFRSF9  1.18154967  TRUE
147 1_39   1 39PARK7  1.18154967  TRUE
148 1_39   1 39   ERRFI1  1.18154967  TRUE
149 1_40   1 40  no_gene  1.79796879 FALSE
150 1_41   1 41  SLC45A1  0.20193560 FALSE

I want to create two new columns, xp.bg and xp.n.top, using the
following criteria:

If gene is the same in consecutive rows, xp.bg is the minimum value of
xp.norm in those rows; if gene is not the same, xp.bg is simply the
value of xp.norm for that row;

Likewise, if there's a run of contiguous xp.top = TRUE values,
xp.n.top is the minimum value in that range, and if xp.top is false or
NA, xp.n.top is NA, or 0 (I don't care).

So, in the above example,
xp.bg for rows 136:141 should be 0.64794094, and is equal to xp.norm
for all other rows,
xp.n.top for row 137 is 1.40312732, 1.18154967 for rows 141:148, and
0/NA for all other rows.

Is there a way to combine indexing and if statements or some such to
accomplish this? I want to it this without using split(main.table,
main.table$gene), because there's about 20,000 unique entries for
gene, and one of the entries, no_gene, is repeated throughout. I
thought briefly of subsetting the rows where xp.top is TRUE, but I
then don't know how to set the range for min, so that it only looks at
what would originally have been consecutive rows, and searching the
help has not proved particularly useful.

Thanks in advance,
Irene Gallego Romero


-- 
Irene Gallego Romero
Leverhulme Centre for Human Evolutionary Studies
University of Cambridge
Fitzwilliam St
Cambridge
CB1 3QH
UK
email: ig...@cam.ac.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Scientific Format E

2009-08-05 Thread Wittmer, Irene

Dear Helpers,

I would like to export a large dataset to a txt file in order to use it
in an other programm. 
Unfurtunatly the R the scientific format is a small e:

2 e-1

while the other programm requires the format to be a capital E:

2E-1

How can I change this in R? 

Thanks for your help

PS: I already found the command to turn them into a non scientific
format (scientific=FALSE)



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How estimate VAR(p)-model robustly?

2009-04-20 Thread Irene Schreiber
Hello,

 

Does anyone know about robust estimation of vector autoregressive models
(VAR(p)) in R? Or in Matlab?

Currently I am using the function ar().

The problem is, that the variances of my data change a lot with time, and we
also have some outliers in the data. That is why, I presume, that we would
get quite different results when estimating robustly.

 

I would be very grateful if someone could help!

Thanks a lot!

 

Irene.

 

 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ARMA-GARCH package in R?

2009-04-06 Thread Irene Schreiber
Hello,

 

Does anyone know about an R-package on multivariate ARMA-GARCH models? Or in
Matlab?

 

I would be very grateful if someone could help!

Thanks a lot!

 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sliding window over irregular intervals

2009-03-30 Thread Irene Gallego Romero

Dear all,

I have some very big data files that look something like this:

id chr pos ihh1 ihh2 xpehh
rs5748748 22 15795572 0.0230222 0.0268394 -0.153413
rs5748755 22 15806401 0.0186084 0.0268672 -0.367296
rs2385785 22 15807037 0.0198204 0.0186616 0.0602451
rs1981707 22 15809384 0.0299685 0.0176768 0.527892
rs1981708 22 15809434 0.0305465 0.0187227 0.489512
rs11914222 22 15810040 0.0307183 0.0172399 0.577633
rs4819923 22 15813210 0.02707 0.0159736 0.527491
rs5994105 22 15813888 0.025202 0.0141296 0.578651
rs5748760 22 15814084 0.0242894 0.0146486 0.505691
rs2385786 22 15816846 0.0173057 0.0107816 0.473199
rs1990483 22 15817310 0.0176641 0.0130525 0.302555
rs5994110 22 15821524 0.0178411 0.0129001 0.324267
rs17733785 22 15822154 0.0201797 0.0182093 0.102746
rs7287116 22 15823131 0.0201993 0.0179028 0.12069
rs5748765 22 15825502 0.0193195 0.0176513 0.090302

I'm trying to extract the maximum and minimum xpehh (last column) values 
within a sliding window (non overlapping), of width 1 (calculated 
relative to pos (third column)). However, as you can tell from the brief 
excerpt here, although all possible intervals will probably be covered 
by at least one data point, the number of data points will be variable 
(incidentally, if anyone knows of a way to obtain this number, that 
would be lovely), as will the spacing between them. Furthermore, values 
of chr (second column) will range from 1 to 22, and values of pos will 
be overlapping across them; I want to evaluate the window separately for 
each value of chr.


I've looked at the help and FAQ on sliding windows, but I'm a relative 
newcomer to R and cannot find a way to do what I need to do. Everything 
I've managed to unearth so far seems geared towards smoother time 
series. Any help on this problem would be vastly appreciated.


Thanks,
Irene

--
Irene Gallego Romero
Leverhulme Centre for Human Evolutionary Studies
University of Cambridge
Fitzwilliam St
Cambridge
CB2 1QH
UK

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] package ccgarch - dcc.estimation

2009-02-04 Thread Irene Schreiber
Hello,

 

I am trying to model a bivariate time series called 'residuals' as a
dcc-garch model.

I want to use the function dcc.estimation(a, A, B dcc.para, dvar, model) out
of the package ccgarch to estimate the parameters.

No matter how I tried to define a, A and B, I always got the message Error
in constrOptim(theta = para, f = loglik.dcc2, gr = grad.dcc2, ui = resta,  :


  initial value not feasible.

As my knowledge about GARCH is rather poor, I might have defined some input
values in an incorrect way.

E.g. this is a part of my code:

a - rep(0,2)

A - diag(2)

B - diag(2)

dcc.para - rep(0,2)

dvar - residuals

model - 'diagonal'

dcc.estimation(a, A, B, dcc.para, dvar, model)

 

I would be very grateful if someone could help!

Thanks a lot!

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] package ccgarch - dcc.estimation

2009-02-04 Thread Irene Schreiber
Hello,

 

I am trying to model a bivariate time series called 'residuals' as a
dcc-garch model.

I want to use the function dcc.estimation(a, A, B dcc.para, dvar, model) to
estimate the parameters.

No matter how I tried to define a, A and B, I always got the message Error
in constrOptim(theta = para, f = loglik.dcc2, gr = grad.dcc2, ui = resta,  :


  initial value not feasible.

As my knowledge about GARCH is rather poor, I might have defined some input
values in an incorrect way.

E.g. this is a part of my code:

a - rep(0,2)

A - diag(2)

B - diag(2)

dcc.para - rep(0,2)

dvar - residuals

model - 'diagonal'

dcc.estimation(a, A, B, dcc.para, dvar, model)

 

I would be very grateful if someone could help!

Thanks a lot!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] preprocessCore

2008-12-12 Thread irene . vicari


Bonjour!
Je suis en train de faire un projet utilisant Affymatrix mais j'ai un problème à
télécharger un package depuis R: une fois que je télécharge le package et je
demande de faire rma ca sort l'erreur suivante et je n'ai aucune idée de
comment je pourrais faire.

 library(preprocessCore)
 plac.rma - rma(plac.new)
Background correcting
Normalizing
Calculating Expression
Errore in rma(plac.new) :
  function 'R_subColSummarize_medianpolish_log' not provided by package
'preprocessCore'

Est-ce que vous avez un conseil à me donner? J'ai un projet à finir et je suis
complètement bloquée :(

Merci d'avance,
Irene Vicari

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Confidence intervals for non-lm curve

2008-06-26 Thread Irene Mantzouni
Hi all!
 
I would like to estimate confidence intervals for a non lm model. 
For example, I use a mixed model of the form:
 
 md=lme(y~x1+I(x1^2)+x2 ...)
 
Parameters x1+I(x1^2) are fixed effects and I would like to plot the predicted 
(partial) curve corresponding to these ones, along with 90% CI bands. 
 
Thus, I  simulate (partial) predictions:
 
Lx=c()
Ux=c()
Mx=c()
z=c()
for (j in 1:length(x1)){
x=x1[j]
for(i in 1:2000){ 
s1 - rnorm(1,.026,.027)  #  mean and sd estimated by lme for x1
s2 - rnorm(1,-.01,.005)  #  mean and sd estimated by lme for I(x1^2)
z[i] - s1*x+s2*(x^2)
} 
Lx[j]=quantile(z,.05)
Ux[j]=quantile(z,.95)
Mx[j]=mean(z)
}

And then plot vectors Lx, Mx and Ux for lower, mean and upper curves, 
respectively. 
 
Is this approach correct? 
 
Any alternatives?
 
Thank you!! 
 
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Confidence intervals for non-lm curve

2008-06-26 Thread Irene Mantzouni

 
Hi all!
 
I would like to estimate confidence intervals for a non lm model. 
For example, I use a mixed model of the form:
 
 md=lme(y~x1+I(x1^2)+x2 ...)
 
Parameters x1+I(x1^2) are fixed effects and I would like to plot the predicted 
(partial) curve corresponding to these ones, along with 90% CI bands. 
 
Thus, I  simulate (partial) predictions:
 
Lx=c()
Ux=c()
Mx=c()
z=c()
for (j in 1:length(x1)){
x=x1[j]
for(i in 1:2000){ 
s1 - rnorm(1,.026,.027)  #  mean and sd estimated by lme for x1
s2 - rnorm(1,-.01,.005)  #  mean and sd estimated by lme for I(x1^2)
z[i] - s1*x+s2*(x^2)
} 
Lx[j]=quantile(z,.05)
Ux[j]=quantile(z,.95)
Mx[j]=mean(z)
}

And then plot vectors Lx, Mx and Ux for lower, mean and upper curves, 
respectively. 
 
Is this approach correct? 
 
Any alternatives?
 
Thank you!! 
 
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] acf function

2008-05-08 Thread Irene Mantzouni
Dear all, 

 

I have an annual time-series of population numbers and I would like to
estimate the auto-correlation. Can I use acf() function and judge
whether auto-correlation is significant by the plots? The acf array, eg:

 

Autocorrelations of series 'x$log.s.r', by lag

 

 0  1  2  3  4  5  6  7  8  9
10 11 12 

 1.000  0.031 -0.171 -0.451  0.021  0.070  0.238 -0.079 -0.046  0.006
0.188 -0.134 -0.016 

13 14 15 

-0.153  0.146  0.096

 

 gives the auto-correlation at lags 1, 2 Is that right? 

 

Thank you!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] acf function

2008-05-08 Thread Irene Mantzouni
Dear all, 
 
 
I have an annual time-series of population numbers and I would like to
estimate the auto-correlation. Can I use acf() function and judge
whether auto-correlation is significant by the plots? The acf array
produced by this functions gives the auto-correlation at lags 1, 2
Is that right? 
 
 
 
Thank you!

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] points size in plots

2008-05-02 Thread Irene Mantzouni
Dear list, 

 

I would like to produce a plot of variables where the size of the points
will be indicative of their standard errors. 

How is that possible?

 

Thank you!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] partial residuals

2008-05-02 Thread Irene Mantzouni
Dear all, 

 

I am trying to estimate partial residuals for the multiple regression lm
model: 

 

a.lm=lm(y~x1+x2) 

 

I use the function

 residuals(a.lm, type=partial)

 

However, the results are much different when I use the manual method
to get partial residuals for x2 (or for x1): 

 

residuals(a.lm) +b1*x1

 

Where b1 is the estimated coefficient for x1 in the lm model and x1 is
the vector of the first predictor. 

 

What is the difference (or my error) in these methods? 

 

Thank you! 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] non-linear correlation

2008-03-05 Thread Irene Mantzouni
 

Hi all!

 

This is a rather statistical question; 

Which effect sizes (parametric or not) could I use in order to estimate
the amount of non-linear correlation between 2 variables? 

Is it possible to correct for auto-correlation within the correlated
times series? 

Any suggestions for the appropriate packages/ functions are more than
welcome!!

 

Thank you!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] regression with error in predictor

2008-02-19 Thread Irene Mantzouni
Hi all!

 

I am trying to run a regression where the predictor values are not real
data but each is estimated from a different model. So, for each value I
have a mean and variance. 

Which package/function should I use in this case? 

 

Thank you! 

 

Irene


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mean and variance of ratio

2008-02-18 Thread Irene Mantzouni
Hi all!

 

I try to estimate a statistic of the form: (x1-x2)/(y1-y2), where
x1,x2,y1,y2 represent variable means, so each has an estimate and
standard error associated with it. 

How is it possible to estimate the mean and the variance of this ratio? 

 

Thank you!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] autocorrelation by group in mixed model

2008-01-11 Thread Irene Mantzouni
Hi all!
 
(How) is it possible to fit a mixed model with group specific auto-correlation 
structure ? For instance, not all my groups display auto-correlation so I would 
like to use a corMatrix (corAR1) only for the auto-correlated ones. If I 
construct manually a
the corMatrix, is it possible to use it  as input somehow?
 
thank you!
 
Irene

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] level significance

2007-12-08 Thread Irene Mantzouni
Hi all!
 
I am fitting a (mixed) model with a factor (F) and continuous response and 
predictor:
y~F+F:x
 
(How) can I check the significance of the model at each factor level (i.e. the 
model could be significant only at one of the levels)?
 
Thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interaction of continuous terms

2007-11-28 Thread Irene Mantzouni
Hi all!
 
this is a rather statistical question:
is it meaningful to consider an interaction effect between 2 continuous 
covariates?
for example: lm(y~x1+x2+x1:x2) 
Should one of continuous x1, x2 be transformed to a categorical variable, 
i.e. be classified into groups?
Is it easier to interpret the effect if 1 or both are centered to the mean or 
z-transformed? 
 
Thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] intercept in multiple regression

2007-11-20 Thread Irene Mantzouni
Hi all!
 
Is it possible to model a multiple regression in which the response becomes 
zero when one of the two covariates is zero?  
lm(y~ x1+x2) and y=0 if x1=0. 
However, when x1=0, y=x2+1(intercept). 
Does this mean I cannot have a second covariate and intercept or should I 
eliminate only the intercept?
 
thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] interpretation for multiple regression

2007-11-12 Thread Irene Mantzouni
Hi!
Yes, I think that you understood it right and made it clear enough to me too!
thank you! :)



Από: Daniel Malter [mailto:[EMAIL PROTECTED]
Αποστολή: Κυρ 11/11/2007 10:55 μμ
Προς: 'Rolf Turner'; Irene Mantzouni
Κοιν.: [EMAIL PROTECTED]
Θέμα: AW: [R] interpretation for multiple regression



Hi,

maybe I don't understand your question correctly, but I don't see a reason
why there should be a significant interaction term at all.

To the question why you regression is linear in B and C:

your regressor B is linear (in B), i.e. B= 1B.
your regressor C is some quadratic function of B, i.e. C=cB^2

As I see it, your C captures the quadratic form of the relationship between
B and A. The relationship between C and A should therefore be linear in the
regression because your C already captures the quadratic form. I.e. your C
cloaks the significant relationship, because C is itself a quadratic
function of B.

Does that make any sense? Or did I understand your question incorrectly?
Daniel


-
cuncta stricte discussurus
-

-Ursprungliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
Auftrag von Rolf Turner
Gesendet: Sunday, November 11, 2007 4:06 PM
An: Irene Mantzouni
Cc: [EMAIL PROTECTED]
Betreff: Re: [R] interpretation for multiple regression


On 10/11/2007, at 3:48 AM, Irene Mantzouni wrote:

 Dear all,

 probably this is quite clear for most of you but for me it is a
 headache...

 I am regressing response A against the continuous covariate B and the
 relationship is clearly quadratic.
 When I add a second covariate B, the relationship becomes linear for
 both B and C.
 So, I expect that the interaction of B:C should also be significant,
 which is not the case.
 How do you interpret this??


Suppose A = a*B + b*C  and C = c*B^2.

Then A = a*B + b*c+B^2 --- quadratic in B.

But the original relationship, predicting A from B and C, is simply
linear in B and C,
no interaction term.

Clear enuff?

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interpretation for multiple regression

2007-11-09 Thread Irene Mantzouni
Dear all,
 
probably this is quite clear for most of you but for me it is a headache...
 
I am regressing response A against the continuous covariate B and the 
relationship is clearly quadratic. 
When I add a second covariate B, the relationship becomes linear for both B and 
C. 
So, I expect that the interaction of B:C should also be significant, which is 
not the case.
How do you interpret this??
 
Thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mixed model testing

2007-11-07 Thread Irene Mantzouni
Is there a formal way to prove the need of a mixed model, apart from e.g. 
comparing the intervals estimated by lmList fit? 
For example, should I compare (with AIC ML?) a model with seperately (unpooled) 
estimated fixed slopes (i.e.using an index for each group) with a model that 
treats this parameter as a random effect (both models treat the remaining 
parameters as random)?
 
Thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] hierarchical mixed model

2007-11-04 Thread Irene Mantzouni
 
I would like to fit a 2-level mixed model:
 
yit=a+a[i]+a[it] +(b+b[i]+b[it])*xit+eps[it]
 
However, the variance of the second level components should depend on the 
group, i.e. sigma for a[it] and b[it] should be [i] specific. 
I do not know whether this is conceptually right in the mixed model context...
In case it stands, how should the formula look like? 
 
Also, the data are unbalanced with different number of observations t nested in 
each i group and I get the warning when trying to fit the model in the 
traditional way. 
How much should I worry about this? 
 
Thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] coef se in lme

2007-11-02 Thread Irene Mantzouni
Thank you very much for the reply (and hopefully I am replying back in the 
proper way). 
Do you think the delta method would be an acceptable way to estimate 
approximate confidence intervals for the resulting group specific coefficients 
(combining fixed effects and BLUPS)? 
Regarding the MCMC related approach, how is it possible to save the fixed and 
the
random effects from the MCMC chain? Can this be implemented through nlme 
library or is there some more clear cut way (I wish I had a strong statistical 
background and abilities but... :)) to evaluate the empirical distribution of a 
parameter that is linear combination of these quantities? 

All the best,
Irene
 



Από: [EMAIL PROTECTED] εκ μέρους Douglas Bates
Αποστολή: Τετ 17/10/2007 10:04 μμ
Προς: Doran, Harold
Κοιν.: Irene Mantzouni; [EMAIL PROTECTED]; R-SIG-Mixed-Models
Θέμα: Re: [R] coef se in lme



On 10/15/07, Doran, Harold [EMAIL PROTECTED] wrote:
 ?vcov

The vcov method returns the estimated variance-covariance matrix of
the fixed-effects only.  I think Irene's question is about the
combination of the fixed-effects parameters and the BLUPs of the
random effects that is returned by the coef method applied to an lmer
object.  (You may recall that you were the person who requested such a
method in lme4 like the coef method in nlme :-)

On the face of it this quantity should be easy to define and evaluate
but in fact it is not easy to do so because these are combinations of
model parameters (the fixed effects) and unobserved random variables
(the random effects).  It gets a bit tricky trying to decide what the
variance of this combination would be.  I think there is a sensible
definition, or at least a computationally reasonable definition, but
there are still a few slippery points in the argument.

Lately I have taken to referring to the estimates of the random
effects, what are sometimes called the BLUPs or Best Linear Unbiased
Predictors, as the conditional modes of the random effects.  That
is, they are the values that maximize the density of the random
effects given the observed data and the values of the model
parameters.  For a linear mixed model the conditional distribution of
the random effects is multivariate normal so the conditional modes are
also the conditional means.  Also, we can evaluate the conditional
variance-covariance matrix of the random effects up to a scale factor.

The next part is where things get a bit hazy for me but I think it
makes sense to consider the joint distribution of the estimator of the
fixed-effects parameters and the random effects conditional on the
data and, possibly, on the variance components.  Conditional on the
relative variance-covariance of the random effects (i.e. the matrix
that occurs as the penalty term in the penalized least squares
representation of the model) the joint distribution of the
fixed-effects estimators and the random effects is multivariate normal
with mean and variance-covariance matrix determined from the
mixed-model equations.

This big (p+q by p+q, where p is the dimension of the fixed effects
and q is the dimension of the random effects) variance-covariance
matrix could be evaluated and, from that, the variance of any linear
combination of components.  However, I have my doubts about whether it
is the most sensible answer to evaluate.  Conditioning on the relative
variance-covariance matrix of the random effects is cheating, in a
way.  It would be like saying we have a known variance, $\sigma^2$
when, in fact, we are using an estimate.  The fact that we don't know
$\sigma^2$ is what gives rise to the t distributions and F
distributions in linear models and we are all trained to pay careful
attention to the number of degrees of freedom in that estimate and how
it affects our ideas of the precision of the estimates of other model
parameters.  For mixed models, though, many practioners are quite
comfortable conditioning on the value of some of the variance
components but not others.  It could turn out that conditioning on the
relative variance-covariance of the random effects is not a big deal
but I don't know.  I haven't examined it in detail and I don't know of
others who have.

Another approach entirely is to use Markov chain Monte Carlo to
examine the joint distribution of the parameters (in the Bayesian
sense) and the random effects.  If you save the fixed effects and the
random effects from the MCMC chain then you can evaluate the linear
combination of interest throughout the chain and get an empirical
distribution of the quantities returned by coef.

This is probably an unsatisfactory answer for Irene who may have
wanted something quick and simple.  Unfortunately, I don't think there
is a quick, simple answer here.

I suggest we move this discussion to the R-SIG-Mixed-Models list which
I am cc:ing on this reply.

 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Irene Mantzouni
 Sent: Mon 10/15/2007 3:20 PM
 To: [EMAIL

[R] coef se in lme

2007-10-15 Thread Irene Mantzouni
Hi all!
 
How is it possible to estimate  standard errors for coef obtained from lme?
Is there sth like se.coef() for lmer or what is the anaytical solution?
 
Thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] weird (?) resid(.) from 2-level lme()

2007-10-10 Thread Irene Mantzouni
Hi all!
 
I am trying to fit a 2-level hierarchical lme(). 
I can extract ranef() and coef() without problems for levels=1:2. 
However, when it comes to resid() at level=2, the resulting list has some 
unnamed entries (label=NA). I checked with my data (NAs have been omitted) 
and I found out that it gives 2-3 residuals less in each subgroup. 
Any ideas what might be wrong? 
 
Thank you!
 
Irene

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] continue for loop in case of erros

2007-10-09 Thread Irene Mantzouni
Thank you all!
Yes, try works!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] constructing a self-starting non-linear model

2007-10-06 Thread Irene Mantzouni
Dear all,
 
I am trying to define a selfStart function for a non-linear model, which is a 
log-transformed SSmicmen model with multiplicative errors and so it is required 
to make them additive:
 
log(y)=log(a)+log(x)-log(1+x/b)
 
 
Any ideas about how to use the peeling method to derive the initial 
argument and get the initial values?
 
Thank you for being always there!:)
 
Irene

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] non-linear model parameterization

2007-09-30 Thread Irene Mantzouni
Dear all,
 
I would like to fit a non-linear model of the form:
y=g*x/(a+b*x)
with nls().
However this model is somehow overparameterized and I get the error message 
about
singular gradient matrix at initial parameter estimates.
What I am interested in is to make inference about parameters b and g, so this 
has to be taken into account in the model formulation. 
What options do I have?
Also, how is it possible to fit a partially linear model? 
 
Thank you!!
 
Irene Mantzouni

PhD student
DIFRES

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.