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


In reply to finding R-squared..please help by david_lyon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.