david_lyon has asked for the wisdom of the Perl Monks concerning the following question:
Bows to the wise perlmonks
Hi I have 2 files:FILE1: <snip> 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 </snip> FILE2: <snip> 2 1 2 2 1 2 2 2 1 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 </snip>
How do I go down each line in each file and work out the $r-squared value for each line in each file. The code I have so far as below.....MANY THANKS IN ADVANCE
#!/usr/bin/perl open (DATA, "FILE1"); @geno = <DATA>; open (DATA2, "FILE2"); @dos = <DATA2>; foreach (1..4){ $num=$_; $dosage = $dos[$num]; $genotype = $geno[$num]; rsquared($dosage, $genotype); } sub rsquared( $dosage =shift; $genotype =shift; ###HELP HERE TO FIND R-squared )
Added in more info as to what R2 is as below, thanks for everyones help The coefficient of determination R2 is used in the context of statistical models whose main purpose is the prediction of future outcomes on the basis of other related information. It is the proportion of variability in a data set that is accounted for by the statistical model.1 It provides a measure of how well future outcomes are likely to be predicted by the model. <code> Thanks for everyones help on this. I have made use of the wondeful code below... One last question in passing: A question in passing do you know why this online calculator http://easycalculation.com/statistics/r-squared.php can find r^2 (but not r) on values: "2,2,2,2" "2,2,2,1" Is that a bug on their software? Thanks again </code
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: finding R-squared..please help
by Eliya (Vicar) on Feb 19, 2012 at 03:16 UTC | |
by david_lyon (Sexton) on Feb 19, 2012 at 23:51 UTC | |
by Eliya (Vicar) on Feb 20, 2012 at 01:10 UTC | |
by david_lyon (Sexton) on Feb 20, 2012 at 16:36 UTC | |
|
Re: finding R-squared..please help
by choroba (Cardinal) on Feb 18, 2012 at 21:07 UTC | |
|
Re: finding R-squared..please help
by LonelyPilgrim (Beadle) on Feb 18, 2012 at 21:09 UTC | |
by JavaFan (Canon) on Feb 18, 2012 at 21:42 UTC | |
by LonelyPilgrim (Beadle) on Feb 18, 2012 at 21:50 UTC |