Re: [R] signal handling
On Fri, 12 Aug 2005, Paul Gilbert wrote: Omar Lakkis wrote: Is ther a signal handling model in R? similar to Perl's %SIG hash. I want to do fast clean up in my R code before exit when a kill signal is issued. I'm not sure about perl's signals, but Unix signals can be passed with q(yes/no, status=whatever) See ?q. This is pretty useful for passing signal to make, for example. That's a return code though, not a signal. -- SIGSIG -- signature too long (core dumped) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] retrieving large columns using RODBC
Hi, I have a large table in Postgresql (result of an MCMC simulation, with 1 million rows) and I would like to retrive colums (correspond to variables) using RODBC. I have a column called index which is used to order rows. Unfortunately, sqlQuery can't return all the values from a column at once (RODBC complains about lack of memory). So I am using the following code: getcolumns - function(channel, tablename, colnames, totalrows, ordered=TRUE,chunksize=1e5) { r - matrix(double(0),totalrows,length(colnames)) for (i in 1:ceiling(totalrows/chunksize)) { cat(.) r[((i-1)*chunksize+1):(i*chunksize)] - as.matrix( sqlQuery(channel, paste(SELECT, paste(colnames,collapse=, ), FROM, tablename, WHERE index =, i*chunksize, AND index , (i-1)*chunksize, if (ordered) ORDER BY index; else ;))) } cat(\n) drop(r) # convert to vector if needed } to retrieve it in chunks. However, this is very slow -- takes about 15 minutes on my machine. Is there a way to speed it up? I am running Linux on a powerbook, RODBC version 1.1-4, R 2.1.1. The machine has only 512 Mb of RAM. Thanks, Tamas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Help converting a function from S-Plus to R: family$weight
I think a question about the S family() functions is best determined by reading the S(-PLUS) documentation. The weights component computes the working weights for the IWLS, unsurprisingly (and as stated by ?family.object). R has mu.eta to do that, the crucial line in R's glm.fit being w - sqrt((weights[good] * mu.eta.val[good]^2)/variance(mu)[good]) But you don't need to port S-only features to R. You do need to worry about R-only features. On Fri, 12 Aug 2005, Peter Dunn wrote: Hi all I am converting an S-Plus function into R. The S-Plus code uses some of the glm families, and family objects. The family objects in S-Plus and R have many different features, for example: In R: names(Gamma()) [1] family link linkfunlinkinvvariance [6] dev.resids aicmu.eta initialize validmu [11] valideta In S-Plus: names(Gamma()) [1] family names link inversederiv [6] initialize variance deviance weight My question concerns the variable weight in the S-Plus function. I'm not sure what it is. (I have searched the S-Plus mailing list archive, and my S-Plus for linux 6.1 documentation.) For almost all family objects, the weight variable is the same as variance, just weighted (and the former as a function; the later as an expression): Gamma()$variance function(mu) mu^2 Gamma()$weight expression(w * mu^2.) The same applies for most families. So I thought I could determine what this weight variable was. But alas--not the inverse,gaussian: inverse.gaussian()$variance function(mu) mu^3 inverse.gaussian()$weight expression(w/((sqrt(family$variance(mu)) * family$deriv(mu))^2.)) So: - can anyone tell me what this expression weight represents? - why is the inverse.gaussian family different than all others? Thanks in advance. P. My S-Plus version: version Version 6.2.1 for Linux 2.4.18 : 2003 My R version: version _ platform i386-pc-linux-gnu arch i386 os linux-gnu system i386, linux-gnu status major2 minor1.0 year 2005 month04 day 18 language R -- Dr Peter Dunn | Senior Lecturer in Statistics Faculty of Sciences, University of Southern Queensland Web:http://www.sci.usq.edu.au/staff/dunn Email: dunn at usq.edu.au CRICOS: QLD 00244B | NSW 02225M | VIC 02387D | WA 02521C __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Penalized likelihood-ratio chi-squared statistic: L.R. model for Goodness of fit?
Dear R list, From the lrm() binary logistic model we derived the G2 value or the likelihood-ratio chi-squared statistic given as L.R. model, in the output of the lrm(). How can this value be penalized for non-linearity (we used splines in the lrm function)? lrm.iRVI - lrm(arson ~ rcs(iRVI,5), penalty=list(simple=10,nonlinear=100,nonlinear.interaction=4)) This didnt work properly. The aim is to obtain a value that can be used to compare the goodness of fit of the different univariate binary logistic models. (The lower the value, the better the fit) Kind regards, Jan Ir. Jan Verbesselt Research Associate Group of Geomatics Engineering Department Biosystems ~ M³-BIORES Vital Decosterstraat 102, 3000 Leuven, Belgium Tel: +32-16-329750 Fax: +32-16-329760 http://gloveg.kuleuven.ac.be/ ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Including Fortran subrutines in a package
Hello! I am creating a packege and I would like to inclued some Fortrun subrutines. I have two questions. 1. Can I use free form fortan - compiles well usinf g77 -ffree-form. 2. Is it enough to place the .for files in scr folder? Thank you in advance for any help! Ales Ziberna P.S.: I am runing R 2.1.1 on Win XP, SP2. I installed rtools, mingw, perl as suggested in the manuals. Here are some detailsabour R: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor1.1 year 2005 month06 day 20 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problems runing R CMD check
Hello! I have a problem checking the package. Firstly, I do not know how to specify the package to check. I tied specify it by supplying the path and by runing the R CMD check in the directory of the package. In addition to that, I get an error bellow. Any suggestions on how to set TMPDIR would be greatly appriciated! C:\Ales\Statistika\Blocno modeliranje\dr\blockmodelingR CMD check * checking for working latex ...Error: environment variable TMPDIR not set (or s et to unusable value) and no default available. at D:\PROGRA~1\R\rw2011\share\perl/R/Utils.pm line 72 Thank you in advance for any help! Ales Ziberna P.S.: I am runing R 2.1.1 on Win XP, SP2. I installed rtools, mingw, perl as suggested in the manuals.Here are some details about R: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor1.1 year 2005 month06 day 20 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems runing R CMD check
hi! start - control panel - system - advanced - environmental variables probably better to be working in a directory with no spaces in the path... s/ On 13/08/05, Aleš Žiberna [EMAIL PROTECTED] wrote: Hello! I have a problem checking the package. Firstly, I do not know how to specify the package to check. I tied specify it by supplying the path and by runing the R CMD check in the directory of the package. In addition to that, I get an error bellow. Any suggestions on how to set TMPDIR would be greatly appriciated! C:\Ales\Statistika\Blocno modeliranje\dr\blockmodelingR CMD check * checking for working latex ...Error: environment variable TMPDIR not set (or s et to unusable value) and no default available. at D:\PROGRA~1\R\rw2011\share\perl/R/Utils.pm line 72 Thank you in advance for any help! Ales Ziberna P.S.: I am runing R 2.1.1 on Win XP, SP2. I installed rtools, mingw, perl as suggested in the manuals.Here are some details about R: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor1.1 year 2005 month06 day 20 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] simulate the data set having the same covariance matrix
Dear list, I have the set of multidimensional vectors X1,.,Xn and I need to simulate the data set having the same covariance matrix, as for X1,.., Xn. Do someone know how it can be done in R? I appreciate your help. Best regards Galina __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] need help
Weiwei Shi wrote: Hi, there: I think i need to re-phrase my question since last time I did not get any reply but i think the question is not that hard, probably i did not make the question clear: I want to find cases like 35, 90, 330, 330, 335 from the rest which look like 3, 3, 3, 3.2, 3.3 4, 4.4, 4.5, 4.6, 4.7 basically there is one (or more) big 'gap' in the case i seek. Hi Weiwei, I think your method of defining a central value for the large proportion of values and then setting a criterion for outliers is valid (or at least as valid as many other ways of defining outliers). However, here is a different method, sorting the vector of values and then looking for a gap with a specified multiple (gap.prop) of the mean differences between the smaller values. It returns the first value after the gap (easily changed to all the values after). To account for vectors that have negative values the minimum value is subtracted when calculating newx and then added to the result. For your data, a gap.prop of 20 works, but the default value of 10 doesn't. It also won't work where large values are typical and small ones are the outliers (well, it will indicate where the gap is). Jim find.first.gap-function(x,gap.prop=10) { lenx-length(x) newx-sort(x)-min(x) not.found-1 gap.pos-2 # set the mean.diff-newx[2]-newx[1] while(not.found gap.pos = lenx) { this.diff-newx[gap.pos]-newx[gap.pos-1] print(c(mean.diff,this.diff)) if(mean.diff != 0) { if(this.diff/mean.diff = gap.prop) not.found-0 else gap.pos-gap.pos+1 } else gap.pos-gap.pos+1 mean.diff-(this.diff+mean.diff*(gap.pos-1))/gap.pos } return(newx[gap.pos]+min(x)) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems runing R CMD check
Please do read the manuals before posting, as we ask in the posting guide. On Sat, 13 Aug 2005, [iso-8859-2] Alea }iberna wrote: I have a problem checking the package. Firstly, I do not know how to specify the package to check. I tied specify it by supplying the path and by runing the R CMD check in the directory of the package. Both work. In addition to that, I get an error bellow. Any suggestions on how to set TMPDIR would be greatly appriciated! This is answered in the R-admin manual, even giving an example! Note also the comments in the R-exts manual about paths with spaces in. C:\Ales\Statistika\Blocno modeliranje\dr\blockmodelingR CMD check * checking for working latex ...Error: environment variable TMPDIR not set (or s et to unusable value) and no default available. at D:\PROGRA~1\R\rw2011\share\perl/R/Utils.pm line 72 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] simulate the data set having the same covariance matrix
library(MASS) ?mvrnorm Note the 'empirical' argument. On Sat, 13 Aug 2005, Glazko, Galina wrote: I have the set of multidimensional vectors X1,.,Xn and I need to simulate the data set having the same covariance matrix, as for X1,.., Xn. Do someone know how it can be done in R? I appreciate your help. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to make a lagged variable in panel data?
Suppose we observe N individuals, for each of which we have a time-series. How do we correctly create a lagged value of the time-series variable? As an example, suppose I create: A - data.frame(year=rep(c(1980:1984),3), person= factor(sort(rep(1:3,5))), wage=c(rnorm(15))) A year personwage 1 1980 1 0.17923212 2 1981 1 0.25610292 3 1982 1 0.50833655 4 1983 1 -0.42448395 5 1984 1 0.49233532 6 1980 2 -0.49928025 7 1981 2 0.06842660 8 1982 2 0.65677575 9 1983 2 0.15947390 10 1984 2 -0.46585116 11 1980 3 -0.29052635 12 1981 3 -0.27109203 13 1982 3 -0.76168164 14 1983 3 0.02294361 15 1984 3 2.22828032 What I'd like to do is to make a lagged wage for each person, i.e., I should get an additional variable A$wage.lag1: A year personwage wage.lag1 1 1980 1 0.17923212 NA 2 1981 1 0.25610292 0.17923212 3 1982 1 0.50833655 0.25610292 4 1983 1 -0.42448395 0.50833655 5 1984 1 0.49233532-0.42448395 6 1980 2 -0.49928025 NA 7 1981 2 0.06842660-0.49928025 8 1982 2 0.65677575 0.06842660 9 1983 2 0.15947390 0.65677575 10 1984 2 -0.46585116 0.15947390 11 1980 3 -0.29052635 NA 12 1981 3 -0.27109203-0.29052635 13 1982 3 -0.76168164-0.27109203 14 1983 3 0.02294361-0.76168164 15 1984 3 2.22828032 0.02294361 I could think of writing code which does this by hand, but it struck me as a fundamental requirement when dealing with panel data, so perhaps there is high level support for such a task? I have been trying to learn groupedData objects and the tools that go with them, but I didn't get a hint about how I would address such a task. -Ila __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to change the names in tone pitch column
Hi, I have a column (V4) in a midi event list which includes tone pitch names, i.e. A4, E4, C#4, A3...: compo[1:10,] V1 V2 V3 V4 V5 V6 V7 1 1 1 0 A4 96 2 0 2 1 1 0 E4 96 2 0 3 1 1 0 C#4 96 2 0 4 1 1 0 A3 96 2 0 5 1 3 0 B4 96 1 0 6 1 3 0 E4 96 1 0 7 1 3 0 B3 96 1 0 8 1 3 0 G#3 96 1 0 9 1 4 0 C#5 96 1 0 10 1 4 0 D4 96 0 512 Now I'd like to change them to pitch classes (column pc here, which has the values between 0-11, using modulo 12) and absolute midi numbers (column pcAb, values 0-107), so as results A4 gives 9 and 57 (and for example C0 gives 0 and O, C2- 0 and 24 etc): compo[1:10,] V1 V2 V3 V4 V5 V6 V7 pc pcAb 1 1 1 0 A4 96 2 0 9 57 2 1 1 0 E4 96 2 0 4 52 3 1 1 0 C#4 96 2 0 1 49 4 1 1 0 A3 96 2 0 9 45 5 1 3 0 B4 96 1 0 11 59 6 1 3 0 E4 96 1 0 4 52 7 1 3 0 B3 96 1 0 11 47 8 1 3 0 G#3 96 1 0 8 44 9 1 4 0 C#5 96 1 0 1 61 10 1 4 0 D4 96 0 512 2 50 I have done it this way (see next under this comment), but there must be some shorter way, using for-loop and paste-command with sep= or some other way?: ##*# ## Create pitch class vector (add column pc to compo file) from column V4: ##*# pc=c(); pc[V4==C0|V4==C1|V4==C2|V4==C3|V4==C4|V4==C5|V4==C6|V4==C7|V4==C8]=0; pc[V4==C#0|V4==C#1|V4==C#2|V4==C#3|V4==C#4|V4==C#5|V4==C#6|V4==C#7|V4==C#8]=1; pc[V4==D0|V4==D1|V4==D2|V4==D3|V4==D4|V4==D5|V4==D6|V4==D7|V4==D8]=2; pc[V4==D#0|V4==D#1|V4==D#2|V4==D#3|V4==D#4|V4==D#5|V4==D#6|V4==D#7|V4==D#8]=3; pc[V4==E0|V4==E1|V4==E2|V4==E3|V4==E4|V4==E5|V4==E6|V4==E7|V4==E8]=4; pc[V4==F0|V4==F1|V4==F2|V4==F3|V4==F4|V4==F5|V4==F6|V4==F7|V4==F8]=5; pc[V4==F#0|V4==F#1|V4==F#2|V4==F#3|V4==F#4|V4==F#5|V4==F#6|V4==F#7|V4==F#8]=6; pc[V4==G0|V4==G1|V4==G2|V4==G3|V4==G4|V4==G5|V4==G6|V4==G7|V4==G8]=7; pc[V4==G#0|V4==G#1|V4==G#2|V4==G#3|V4==G#4|V4==G#5|V4==G#6|V4==G#7|V4==G#8]=8; pc[V4==A0|V4==A1|V4==A2|V4==A3|V4==A4|V4==A5|V4==A6|V4==A7|V4==A8]=9; pc[V4==A#0|V4==A#1|V4==A#2|V4==A#3|V4==A#4|V4==A#5|V4==A#6|V4==A#7|V4==A#8]=10; pc[V4==B0|V4==B1|V4==B2|V4==B3|V4==B4|V4==B5|V4==B6|V4==B7|V4==B8]=11; ## ... and absolute pitches (0-107): pcAb=c(); pcAb[V4==C0]=0;pcAb[V4==C#0]=1;pcAb[V4==D0]=2;pcAb[V4==D#0]=3;pcAb[V4==E0]=4;pcAb[V4==F0]=5;pcAb[V4==F#0]=6;pcAb[V4==G0]=7;pcAb[V4==G#0]=8;pcAb[V4==A0]=9;pcAb[V4==A#0]=10;pcAb[V4==B0]=11; pcAb[V4==C1]=12;pcAb[V4==C#1]=13;pcAb[V4==D1]=14;pcAb[V4==D#1]=15;pcAb[V4==E1]=16;pcAb[V4==F1]=17;pcAb[V4==F#1]=18;pcAb[V4==G1]=19;pcAb[V4==G#1]=20;pcAb[V4==A1]=21;pcAb[V4==A#1]=22;pcAb[V4==B1]=23; pcAb[V4==C2]=24;pcAb[V4==C#2]=25;pcAb[V4==D2]=26;pcAb[V4==D#2]=27;pcAb[V4==E2]=28;pcAb[V4==F2]=29;pcAb[V4==F#2]=30;pcAb[V4==G2]=31;pcAb[V4==G#2]=32;pcAb[V4==A2]=33;pcAb[V4==A#2]=34;pcAb[V4==B2]=35; pcAb[V4==C3]=36;pcAb[V4==C#3]=37;pcAb[V4==D3]=38;pcAb[V4==D#3]=39;pcAb[V4==E3]=40;pcAb[V4==F3]=41;pcAb[V4==F#3]=42;pcAb[V4==G3]=43;pcAb[V4==G#3]=44;pcAb[V4==A3]=45;pcAb[V4==A#3]=46;pcAb[V4==B3]=47; pcAb[V4==C4]=48;pcAb[V4==C#4]=49;pcAb[V4==D4]=50;pcAb[V4==D#4]=51;pcAb[V4==E4]=52;pcAb[V4==F4]=53;pcAb[V4==F#4]=54;pcAb[V4==G4]=55;pcAb[V4==G#4]=56;pcAb[V4==A4]=57;pcAb[V4==A#4]=58;pcAb[V4==B4]=59; pcAb[V4==C5]=60;pcAb[V4==C#5]=61;pcAb[V4==D5]=62;pcAb[V4==D#5]=63;pcAb[V4==E5]=64;pcAb[V4==F5]=65;pcAb[V4==F#5]=66;pcAb[V4==G5]=67;pcAb[V4==G#5]=68;pcAb[V4==A5]=69;pcAb[V4==A#5]=70;pcAb[V4==B5]=71; pcAb[V4==C6]=72;pcAb[V4==C#6]=73;pcAb[V4==D6]=74;pcAb[V4==D#6]=75;pcAb[V4==E6]=76;pcAb[V4==F6]=77;pcAb[V4==F#6]=78;pcAb[V4==G6]=79;pcAb[V4==G#6]=80;pcAb[V4==A6]=81;pcAb[V4==A#6]=82;pcAb[V4==B6]=83; pcAb[V4==C7]=84;pcAb[V4==C#7]=85;pcAb[V4==D7]=86;pcAb[V4==D#7]=87;pcAb[V4==E7]=88;pcAb[V4==F7]=89;pcAb[V4==F#7]=90;pcAb[V4==G7]=91;pcAb[V4==G#7]=92;pcAb[V4==A7]=93;pcAb[V4==A#7]=94;pcAb[V4==B7]=95; pcAb[V4==C8]=96;pcAb[V4==C#8]=97;pcAb[V4==D8]=98;pcAb[V4==D#8]=99;pcAb[V4==E8]=100;pcAb[V4==F8]=101;pcAb[V4==F#8]=102;pcAb[V4==G8]=103;pcAb[V4==G#8]=104;pcAb[V4==A8]=105;pcAb[V4==A#8]=106;pcAb[V4==B8]=107; #* ## Bind vectors pc and pcAb to original composition array: compo=cbind(compo,pc,pcAb); -Atte __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Penalized likelihood-ratio chi-squared statistic: L.R. model for Goodness of fit?
Jan Verbesselt wrote: Dear R list, From the lrm() binary logistic model we derived the G2 value or the likelihood-ratio chi-squared statistic given as L.R. model, in the output of the lrm(). How can this value be penalized for non-linearity (we used splines in the lrm function)? lrm.iRVI - lrm(arson ~ rcs(iRVI,5), penalty=list(simple=10,nonlinear=100,nonlinear.interaction=4)) This didn’t work properly. Please following the posting guide. What do you mean by 'work' and what is the output? You are attempting to penalize for nonexistent interaction terms. Differential penalization is only appropriate if there are many similar terms being penalized (e.g., you fit a multivariable model and want to penalize all nonlinear terms in all variables combined). The aim is to obtain a value that can be used to compare the goodness of fit of the different univariate binary logistic models. By univariate I assume you mean univariable. Penalization is primarily used to fit multivariable models. It allows you to fit bigger models. But for your purpose comparing AIC of various models might be entertained. Frank (The lower the value, the better the fit) Kind regards, Jan Ir. Jan Verbesselt Research Associate Group of Geomatics Engineering Department Biosystems ~ M³-BIORES Vital Decosterstraat 102, 3000 Leuven, Belgium Tel: +32-16-329750 Fax: +32-16-329760 http://gloveg.kuleuven.ac.be/ ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] General expression of a unitary matrix
Google led me to http://mathworld.wolfram.com/SpecialUnitaryMatrix.html;, where I learned that a special unitary matrix U has det(U) = 1 in addition to the unitary matrix requirement that U %*% t(Conj(U)) == diag(dim(U)[1]). Thus, if U is a k x k unitary matrix with det(U) = exp(th*1i), exp(-th*1i/k)*U is a special unitary matrix. Moreover, the special unitary matrices are a group under multiplication. Another Google query led me to http://mathworld.wolfram.com/SpecialUnitaryGroup.html;, which gives a general expression for a special unitary matrix, which seems to require three real numbers, not four; with a fourth, you could get a general unitary matrix. spencer graves J. Liu wrote: Hi, all, Does anybody got the most general expression of a unitary matrix? I found one in the book, four entries of the matrix are: (cos\theta) exp(j\alpha); -(sin\theta)exp(j(\alpha-\Omega)); (sin\theta)exp(j(\beta+\Omega)); (cos\theta) exp(j\beta); where j is for complex. However, since for any two unitary matrices, their product should also be a unitary matrix. When I try to use the above expression to calculate the product, I can not derive the product into the same form. Therefore, I suspect that this may not be the most general expression. Could you help me out of this? Thanks... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] tkinsert matrix - how to display a matrix with tcltk
dear list, I have problems with tkinsert I need to display a matrix as a result of my function, but when I use tkinsert(txt, end, myMatrix, sep=\n) I simply obtain a string. I do: n-tclVar() tclObj(n)-matrix(data, ncol=lenght) tkinsert(txt, end, tclvalue(n), sep=\n) any hints? thank you in advance, simone gabbriellini __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help on cross hedge optimal hedge variance ratio
You have not told us what software you used to get the results you present. My first question is whether you are working with prices or log(prices)? If the former, I suggest you consider the latter; price changes tend to be much better behaved, more nearly normal, etc., on the log scale than in dollars, Euros, Rupias, or whatever. Secondly, have you made a normal probability plot of the residuals, preferably using studres in library(MASS)? (If you don't have Venables and Ripley 2002 Modern Applied Statistis with S, Springer, I recommend you get it and spend some time with it. In addition to studres, it has an excellent chapter devoted to an introductory discussion of time series analysis.) Outliers suggest you may need to be working with some of the more sophisticated Rmetrics tools, but I'm not sufficiently familiar with those to say much more about that at the present time. If I had outliers, I might just delete them initially. However, I would definitely want to come back to them later, because the outliers could provide more information than other observations to predict, for example, a structural change in the market. Modeling and reacting properly to such signals could make the difference between stellar performance and disaster in managing a hedge fund. Thirdly, have you made acf and pacf of the residuals? Also, have you computed the Box-Ljung statistic (function Box.test)? If no, I suggest you do that as a next step. If they indicate some kind of autocorrelation structure, I might then try to model and estimate that along with your regression model using function arima. If you still have questions (which I suspect), then feel free to ask another question. However, before you do that, PLEASE do read the posting guide prior! http://www.R-project.org/posting-guide.html;. Many people find answers to their own questions in the process of working through the posting guide. Questions posted following that process tend to be clearer, easier for others to understand and respond to. On average, this tends to increase the speed, volume and utility of replies. spencer graves Krishna wrote: Hi everyone I am trying to estimate the optimal hedge variance ratio for cross hedging two commodities. the price levels are used (compared to price change and % price change) and used the OLS with dummy variable for estimating the co-efficients. the equation looks like this Y = B + B1*D1 + B2*X + B3*(X*D1) Where Y = Daily Cash market price D1 = Dummy variable taking value 1 for period Oct-Mar and 0 for Apr-Sep X = Daily futures market price on which cross hedging is done. B,B1,B2,B3 are the slope co-efficients. The results look like this Regression Statistics Multiple R0.948702709 R Square 0.900036831 Adjusted R Square 0.89981135 Standard Error25.52050965 Observations 1334 CoefficientsStandard Error t Stat P-value Intercept 53.817 4.375 12.300 0.000 X 0.986 0.012 80.283 0.000 D127.399 6.106 4.487 0.000 D1 * X-0.100 0.017 -5.820 0.000 It is understood the slope co-efficients for different periods are significant as indicated by t-table value. But I feel suspicious on the reliability of this values. I have used 5 years of daily price data for running the regression, and I feel suscpicious becasue, the monthly correlations (pearson correlation co-efficient) are highly varying between spot and futures and some times even negative. Can someone suggest me a) the tests to judge the reliability of hedge-variance values b) Is there any other better method than described here for estimating the hedge-variance values Thank you for the attention and look forward for an early reply rgds snvk __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] When I install from source, chmod not permitted
How to fix: chmod: /Library/Frameworks/R.framework/Versions/2.1.1/Resources/ library/R.css: Operation not permitted Kindly cc me when replying to list. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Compilation failures: mgcv, spatstat, Matrix, cluster
Please cc me when replying to the list. With Version 2.1.1 (2005-06-20) on Power Mac G5 running Mac OS X 10.4.2 (8C46): Some compilations work (e.g., MatchIt, RGraphics, Zelig), and some don't, e.g., mgcv, spatstat, and the following (Matrix, cluster): trying URL 'http://www.ibiblio.org/pub/languages/R/CRAN/src/contrib/ Matrix_0.98-3.tar.gz' Content type 'application/x-tar' length 626712 bytes opened URL == downloaded 612Kb * Installing *source* package 'Matrix' ... ** libs The downloaded packages are in /private/tmp/RtmpPddsAE/downloaded_packages gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ include -I/usr/local/include -I./Metis -fno-common -g -O2 -c HBMM.c -o HBMM.o In file included from HBMM.c:2: iohb.h:6:19: malloc.h: No such file or directory make: *** [HBMM.o] Error 1 ERROR: compilation failed for package 'Matrix' trying URL 'http://www.ibiblio.org/pub/languages/R/CRAN/src/contrib/ cluster_1.10.1.tar.gz' Content type 'application/x-tar' length 190975 bytes opened URL == downloaded 186Kb * Installing *source* package 'cluster' ... ** libs gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ include -I/usr/local/include -fno-common -g -O2 -c clara.c -o clara.o g77 -fno-common -g -O2 -c daisy.f -o daisy.o g77 -fno-common -g -O2 -c dysta.f -o dysta.o g77 -fno-common -g -O2 -c fanny.f -o fanny.o g77 -fno-common -g -O2 -c meet.f -o meet.o g77 -fno-common -g -O2 -c mona.f -o mona.o gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ include -I/usr/local/include -fno-common -g -O2 -c pam.c -o pam.o gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ include -I/usr/local/include -fno-common -g -O2 -c spannel.c -o spannel.o g77 -fno-common -g -O2 -c twins.f -o twins.o The downloaded packages are in /private/tmp/RtmpPddsAE/downloaded_packages gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/local/lib - o cluster.so clara.o daisy.o dysta.o fanny.o meet.o mona.o pam.o spannel.o twins.o -L/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2 -lg2c -lSystem -framework R ** Removing '/Library/Frameworks/R.framework/Versions/2.1.1/Resources/ library/cluster' ** Restoring previous '/Library/Frameworks/R.framework/Versions/2.1.1/ Resources/library/cluster' ld: clara.o has external relocation entries in non-writable section (__TEXT,__text) for symbols: restFP saveFP make: *** [cluster.so] Error 1 ERROR: compilation failed for package 'cluster' _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting a t statistic to r2
The formula R2 = t2/(df+t2) applies only if a single intercept and a single slope are estimate with simple linear regression in something like B~A or B~age, but not with interaction nor quadratic term in age. For further information, I just got 4 hits from 'RSiteSearch(R^2 in lme)', two of which seemed relevant to your question: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/17572.html;, and http://finzi.psych.upenn.edu/R/Rhelp02a/archive/34377.html;. If you still want more help after this, please submit another question -- after reading the posting guide! http://www.R-project.org/posting-guide.html;. The Posting Guide serves two purposes: (a) It helps people get better answers to their questions quicker. (b) It makes it easier for people who try to answer such questions to understand what the questioner wants. It seems to succeeds fairly well on both counts when it is used. I think I can see in a question whether the submitter has paid adequate attention to the posting guide: The questions tend to be better focused, more complete, and easier to understand and reply to. If you want free consulting, you have to pay for it. spencer graves -- Shaw, Philip (NIH/NIMH) wrote: HI I wonder if anyone can help. I have a longitudinal sample of 100 subjects: 200 data points were acquired starting at different ages and at irregular intervals (subjects have different numbers of repeated data points, so some have only one data point). I have been examining the relationship over time (it is quadratic) of continuous variables A on variable B. To model this I have been using linear mixed models in R. B~A*age +A*I(age^2) + random term (for individual) I get t values associated with A, age and A*age. How (or can) the t value for A be converted to a correlation (r) or variance value? I recall that R2 = t2/(df+t2) But can this be applied to linear mixed models and what are the degrees of freedom? I hope this is reasonably clear, Many thanks for any opinions Philip [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] path analysis
Someone knows if it is possible to perform a path analysis with sem package (or any other) to explain a dependent *dichotomus* variable? Thanks, Manel Salamero __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem with numeric variable
Hello all, I posted a question some days ago without getting any answers, perhaps, as one of you kindly pointed out, because the question was not clearly stated. Let me reformulate it: In a frame, a column named C2 represents a numeric variable (checked with is.numeric(C2)). Some rows in the frame have an undefined value for C2, represented in the table by a ? sign. The remaining rows have numeric values with 2 decimals. For example, row 10 has 43.70 for C2, while row 1 has ?. The problem is that when I list C2 values (or when I try to plot them, etc), these values are not the ones that appeared in the table. Below are the first 3 lines of what I get when I list C2: C2 [1] 43 47 96 62 87 55 1 98 121 1 1 1 67 1 112 1 93 44 [19] 85 569 52 110 126 95 92 60 36 383 373 298 274 406 208 175 293 306 [37] 305 172 134 115 94 84 104 99 64 271 269 310 268 359 443 248 204 345 These are not the correct values for C2, and I guess that they are just row numbers. How can I get the correct C2 values ready for analysis? Is this problem related to the fact that some rows have a ? value for C2? Thanks in advance, Francisco Torreira Francisco Torreira Spanish, Italian and Portuguese Univ. of Illinois at Urbana-Champaign 707 South Mathews Aven. 4031 FLB Urbana, IL, 61801 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to change the names in tone pitch column
Thanks Phil! This is much more beautiful and elegant. And I learned 2 new R-functions, nchar and substr. -Atte Atte - Here's one way - there certainly are others: notes = 0:11 names(notes) = c(C,C#,D,D#,E,F,F#,G,G#,A,A#,B) pc = notes[substr(V4,1,nchar(V4) - 1)] names(pc) = NULL pcAb = pc + 12 * as.numeric(substr(V4,nchar(V4),nchar(V4))) names(pcAb) = NULL - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley [EMAIL PROTECTED] On Sat, 13 Aug 2005, Atte Tenkanen wrote: Hi, I have a column (V4) in a midi event list which includes tone pitch names, i.e. A4, E4, C#4, A3...: compo[1:10,] V1 V2 V3 V4 V5 V6 V7 1 1 1 0 A4 96 2 0 2 1 1 0 E4 96 2 0 3 1 1 0 C#4 96 2 0 4 1 1 0 A3 96 2 0 5 1 3 0 B4 96 1 0 6 1 3 0 E4 96 1 0 7 1 3 0 B3 96 1 0 8 1 3 0 G#3 96 1 0 9 1 4 0 C#5 96 1 0 10 1 4 0 D4 96 0 512 Now I'd like to change them to pitch classes (column pc here, which has the values between 0-11, using modulo 12) and absolute midi numbers (column pcAb, values 0-107), so as results A4 gives 9 and 57 (and for example C0 gives 0 and O, C2- 0 and 24 etc): compo[1:10,] V1 V2 V3 V4 V5 V6 V7 pc pcAb 1 1 1 0 A4 96 2 0 9 57 2 1 1 0 E4 96 2 0 4 52 3 1 1 0 C#4 96 2 0 1 49 4 1 1 0 A3 96 2 0 9 45 5 1 3 0 B4 96 1 0 11 59 6 1 3 0 E4 96 1 0 4 52 7 1 3 0 B3 96 1 0 11 47 8 1 3 0 G#3 96 1 0 8 44 9 1 4 0 C#5 96 1 0 1 61 10 1 4 0 D4 96 0 512 2 50 I have done it this way (see next under this comment), but there must be some shorter way, using for-loop and paste-command with sep= or some other way?: ##*# ## Create pitch class vector (add column pc to compo file) from column V4: ##*# pc=c(); pc[V4==C0|V4==C1|V4==C2|V4==C3|V4==C4|V4==C5|V4==C6|V4==C7|V4==C8]=0; pc[V4==C#0|V4==C#1|V4==C#2|V4==C#3|V4==C#4|V4==C#5|V4==C#6|V4==C#7|V4==C#8]=1; pc[V4==D0|V4==D1|V4==D2|V4==D3|V4==D4|V4==D5|V4==D6|V4==D7|V4==D8]=2; pc[V4==D#0|V4==D#1|V4==D#2|V4==D#3|V4==D#4|V4==D#5|V4==D#6|V4==D#7|V4==D#8]=3; pc[V4==E0|V4==E1|V4==E2|V4==E3|V4==E4|V4==E5|V4==E6|V4==E7|V4==E8]=4; pc[V4==F0|V4==F1|V4==F2|V4==F3|V4==F4|V4==F5|V4==F6|V4==F7|V4==F8]=5; pc[V4==F#0|V4==F#1|V4==F#2|V4==F#3|V4==F#4|V4==F#5|V4==F#6|V4==F#7|V4==F#8]=6; pc[V4==G0|V4==G1|V4==G2|V4==G3|V4==G4|V4==G5|V4==G6|V4==G7|V4==G8]=7; pc[V4==G#0|V4==G#1|V4==G#2|V4==G#3|V4==G#4|V4==G#5|V4==G#6|V4==G#7|V4==G#8]=8; pc[V4==A0|V4==A1|V4==A2|V4==A3|V4==A4|V4==A5|V4==A6|V4==A7|V4==A8]=9; pc[V4==A#0|V4==A#1|V4==A#2|V4==A#3|V4==A#4|V4==A#5|V4==A#6|V4==A#7|V4==A#8]=10; pc[V4==B0|V4==B1|V4==B2|V4==B3|V4==B4|V4==B5|V4==B6|V4==B7|V4==B8]=11; ## ... and absolute pitches (0-107): pcAb=c(); pcAb[V4==C0]=0;pcAb[V4==C#0]=1;pcAb[V4==D0]=2;pcAb[V4==D#0]=3;pcAb[V4==E0]=4;pcAb[V4==F0]=5;pcAb[V4==F#0]=6;pcAb[V4==G0]=7;pcAb[V4==G#0]=8;pcAb[V4==A0]=9;pcAb[V4==A#0]=10;pcAb[V4==B0]=11; pcAb[V4==C1]=12;pcAb[V4==C#1]=13;pcAb[V4==D1]=14;pcAb[V4==D#1]=15;pcAb[V4==E1]=16;pcAb[V4==F1]=17;pcAb[V4==F#1]=18;pcAb[V4==G1]=19;pcAb[V4==G#1]=20;pcAb[V4==A1]=21;pcAb[V4==A#1]=22;pcAb[V4==B1]=23; pcAb[V4==C2]=24;pcAb[V4==C#2]=25;pcAb[V4==D2]=26;pcAb[V4==D#2]=27;pcAb[V4==E2]=28;pcAb[V4==F2]=29;pcAb[V4==F#2]=30;pcAb[V4==G2]=31;pcAb[V4==G#2]=32;pcAb[V4==A2]=33;pcAb[V4==A#2]=34;pcAb[V4==B2]=35; pcAb[V4==C3]=36;pcAb[V4==C#3]=37;pcAb[V4==D3]=38;pcAb[V4==D#3]=39;pcAb[V4==E3]=40;pcAb[V4==F3]=41;pcAb[V4==F#3]=42;pcAb[V4==G3]=43;pcAb[V4==G#3]=44;pcAb[V4==A3]=45;pcAb[V4==A#3]=46;pcAb[V4==B3]=47; pcAb[V4==C4]=48;pcAb[V4==C#4]=49;pcAb[V4==D4]=50;pcAb[V4==D#4]=51;pcAb[V4==E4]=52;pcAb[V4==F4]=53;pcAb[V4==F#4]=54;pcAb[V4==G4]=55;pcAb[V4==G#4]=56;pcAb[V4==A4]=57;pcAb[V4==A#4]=58;pcAb[V4==B4]=59; pcAb[V4==C5]=60;pcAb[V4==C#5]=61;pcAb[V4==D5]=62;pcAb[V4==D#5]=63;pcAb[V4==E5]=64;pcAb[V4==F5]=65;pcAb[V4==F#5]=66;pcAb[V4==G5]=67;pcAb[V4==G#5]=68;pcAb[V4==A5]=69;pcAb[V4==A#5]=70;pcAb[V4==B5]=71; pcAb[V4==C6]=72;pcAb[V4==C#6]=73;pcAb[V4==D6]=74;pcAb[V4==D#6]=75;pcAb[V4==E6]=76;pcAb[V4==F6]=77;pcAb[V4==F#6]=78;pcAb[V4==G6]=79;pcAb[V4==G#6]=80;pcAb[V4==A6]=81;pcAb[V4==A#6]=82;pcAb[V4==B6]=83; pcAb[V4==C7]=84;pcAb[V4==C#7]=85;pcAb[V4==D7]=86;pcAb[V4==D#7]=87;pcAb[V4==E7]=88;pcAb[V4==F7]=89;pcAb[V4==F#7]=90;pcAb[V4==G7]=91;pcAb[V4==G#7]=92;pcAb[V4==A7]=93;pcAb[V4==A#7]=94;pcAb[V4==B7]=95; pcAb[V4==C8]=96;pcAb[V4==C#8]=97;pcAb[V4==D8]=98;pcAb[V4==D#8]=99;pcAb[V4==E8]=100;pcAb[V4==F8]=101;pcAb[V4==F#8]=102;pcAb[V4==G8]=103;pcAb[V4==G#8]=104;pcAb[V4==A8]=105;pcAb[V4==A#8]=106;pcAb[V4==B8]=107;
[R] Lattice on Mac OS X Strip Labels
Hi, I'm running R 1.9 on a Mac with OS X (v10.3.9). When I use the lattice package I never see text in the strip labels. The labels appear and I can change their color, size, etc., but no matter what I do, no text appears. When I run the same code on my Unix R, the strip labels appear no problem. Does anyone have any suggestions about how to reconfigure my lattice window? Thanks Jason __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] monte carlo simulations/lmer
Hi - I am doing some monte carlo simulations comparing bayesian (using Plummer's jags) and maximum likelihood (using lmer from package lme4 by Bates et al). I would like to know if there is a way I can flag nonconvergence and exceptions. Currently the simulations just stop and the output reads things like: Error in optim(.Call(lmer_coef, x, 2, PACKAGE = Matrix), fn, gr, method = L-BFGS-B, : L-BFGS-B needs finite values of 'fn' In addition: Warning message: Leading minor of size 1 of downdated X'X is indefinite Error in .local(object, ...) : Leading 2 minor of Omega[[1]] not positive definite In addition: Warning messages: 1: optim or nlminb returned message ERROR: ABNORMAL_TERMINATION_IN_LNSRCH in: LMEoptimize-(`*tmp*`, value = list(maxIter = 200, msMaxIter = 200, 2: optim or nlminb returned message ERROR: ABNORMAL_TERMINATION_IN_LNSRCH in: LMEoptimize-(`*tmp*`, value = list(maxIter = 200, msMaxIter = 200, thanks for any help. -eduardo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] path analysis
Dear Manel, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of SALAMERO BARO, MANUEL Sent: Saturday, August 13, 2005 2:02 PM To: r-help@stat.math.ethz.ch Subject: [R] path analysis Someone knows if it is possible to perform a path analysis with sem package (or any other) to explain a dependent *dichotomus* variable? Yes -- you can use the hetcor() function in the polycor package to generate a correlation matrix and boot.sem() in the sem package to get standard errors or confidence intervals. Make sure that the dichotomous variables are represented as factors. See ?boot.sem for an example. I hope this helps, John __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] monte carlo simulations/lmer
I think you want to use the function try(); see ?try. cheers, Rolf Turner [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to make a lagged variable in panel data?
On 8/13/05, Ila Patnaik [EMAIL PROTECTED] wrote: Suppose we observe N individuals, for each of which we have a time-series. How do we correctly create a lagged value of the time-series variable? As an example, suppose I create: A - data.frame(year=rep(c(1980:1984),3), person= factor(sort(rep(1:3,5))), wage=c(rnorm(15))) A year personwage 1 1980 1 0.17923212 2 1981 1 0.25610292 3 1982 1 0.50833655 4 1983 1 -0.42448395 5 1984 1 0.49233532 6 1980 2 -0.49928025 7 1981 2 0.06842660 8 1982 2 0.65677575 9 1983 2 0.15947390 10 1984 2 -0.46585116 11 1980 3 -0.29052635 12 1981 3 -0.27109203 13 1982 3 -0.76168164 14 1983 3 0.02294361 15 1984 3 2.22828032 What I'd like to do is to make a lagged wage for each person, i.e., I should get an additional variable A$wage.lag1: A year personwage wage.lag1 1 1980 1 0.17923212 NA 2 1981 1 0.25610292 0.17923212 3 1982 1 0.50833655 0.25610292 4 1983 1 -0.42448395 0.50833655 5 1984 1 0.49233532-0.42448395 6 1980 2 -0.49928025 NA 7 1981 2 0.06842660-0.49928025 8 1982 2 0.65677575 0.06842660 9 1983 2 0.15947390 0.65677575 10 1984 2 -0.46585116 0.15947390 11 1980 3 -0.29052635 NA 12 1981 3 -0.27109203-0.29052635 13 1982 3 -0.76168164-0.27109203 14 1983 3 0.02294361-0.76168164 15 1984 3 2.22828032 0.02294361 We can use 'by' to split data frame A by person and to apply the function f to each such subset of rows. Function f makes that portion of wage which corresponds to a single person into a ts class time series so that we can use lag with it and then we cbind wage together with its lag. From the cbind'ed result we extract out those times that correspond to the original series since the example output only includes those. Note that such extraction has a side effect of turning wages into a matrix rather than a time series. We then put every together using cbind(...) once again and once the 'by' is complete we rbind all rows together. f - function(x) { wage - ts(x$wage, start = x$year[1]) idx - seq(length = length(wage)) wages - cbind(wage, lag(wage, -1))[idx,] cbind(x[,1:2], wages) } result - do.call(rbind, by(A, A$person, f)) result __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] PCA problem in R
Dear all: When I have more variables than units, say a 195*10896 matrix which has 10896 variables and 195 samples. prcomp will give only 195 principal components. I checked in the help, but there is no explanation that why this happen. Can we get more than 195 PCs for this case? Thank you very much. Best! Alan Aug-12-2005 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Documents for LME4
Dear All, I want to fit a two-level cross-classified random effect poisson model using LME4. However, the documentation for this pacakge seems really thin. I have the NLME book, but there is not much about mixed generalized linear models. Any suggestions about where I should begin? Thanks! Best, Shige __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html