[R] normalised curve fitting with error bars
David Winsemius
dwinsemius at comcast.net
Fri Jul 3 19:09:07 CEST 2009
On Jul 3, 2009, at 12:52 PM, Pooja Jain wrote:
> Hi David,
>
> Sorry for not being absolutely clear.
>
> x-axis will be the values ranging from (-50 to 50) and y-axis will
> be the density distribution as you would get after plotting every
> column fitted to the normal distribution. However, what I need here
> is to reduce the nine column file to a three column file. In the
> three column file, the first column should be the mean of every row
> of a the nine column file, the second column will be the maximum
> value of every row of the nine column file and the third column will
> be the minimum value of all of the values in every row of the nine
> column file.
>
The three vectors you desire can be created with:
apply(x, 1, mean)
apply(x, 1 ,max)
apply(x ,1, min)
In one line it could be
> new3 <- data.frame(mean50 =apply(x, 1, mean), max50=apply(x, 1,
max), min50= apply(x, 1, min))
Then plot density(new3$mn) and the others.
plot(density(new3$mean50), xlim=c(min(new3$min50),max(new3$max50) ) )
points(density(new3$min50)) # may need to set the ylims if this
overshoots
points(density(new3$max50))
I think....
--
David
> Since the values in the nine column fits quite well to the normal
> distribution, I expect their mean to behave similar. So I would plot
> mean fitted to the normal distribution and would like to see for
> every mean value what is the error bar as defined by the min and max
> values.
>
> Thank you for any help that you may extend in this matter.
>
> Best regards,
> -Pooja
>
> On 3 Jul 2009, at 17:32, David Winsemius wrote:
>
>>
>> On Jul 3, 2009, at 11:56 AM, Pooja Jain wrote:
>>
>>> Dear List,
>>>
>>>
>>> My data consist of nine columns and about 50,000 rows. It looks
>>> like this.
>>>
>>> -9.0225 3.46464 2.80926 -0.3847 3.73735 1.1058 -2.98936
>>> 1.38901 -8.1846
>>> -2.4315 -5.1189 1.8225 3.3798 1.7874 4.693 -3.9286 1.4266 5.7849
>>> -3.4894 -4.0305 3.7879 3.5195 2.9186 2.8685 -6.126 4.978 4.9381
>>> 4.5282 3.62558 -3.0455 4.6518 1.39746 0.68652 3.5708 -3.6404 -4.2963
>>> -1.3183 0.6752 -4.0382 -2.5386 -0.6459 1.0689 -0.6392 -6.4141 -4.101
>>> -1.3735 3.1098 -2.8291 -5.2548 -3.3798 1.3959 -1.8605 0.1522 2.1818
>>> -1.0488 0.1071 -3.7154 -1.3748 -5.6218 -0.9989 -2.6763 -4.6548
>>> 0.5449
>>> 7.948 2.0673 3.8729 8.0537 2.79 -3.6963 8.4584 -1.5122 -6.3354
>>> 4.5827 6.1787 -3.1787 1.4554 5.6973 5.3386 10.6077 -0.0424 3.3653
>>> 4.1653 8.0266 1.9509 4.2077 5.4182 4.1797 7.9248 1.1502 0.753
>>> 3.6046 3.6743 11.8299 9.5704 10.7384 8.675 4.9277 13.6898 13.3279
>>> 18.4431 12.3946 22.1126 22.7109 19.4623 17.3565 15.27 17.5922
>>> 19.5873
>>>
>>>
>>> The values in each of the nine columns are almost normally
>>> distributed but have slightly different heights of nine normalised
>>> bell shaped plots.
>>>
>>> I was trying to plot each row as a point with error bars. The
>>> central point will be the mean of the nine values in each of rows
>>> and the max and min of the row will be the upper and lower bound
>>> of the error bar. I expect a normally distributed plot with
>>> spikes around. Can any one please help me plotting data in this
>>> way ?
>>>
>>> Many thanks for any input.
>>>
>>
>> I am confused about what is desired. First you describe the
>> distributions of the full dataset's columns. Then you ask for a
>> plot by rows, but you say it will be a normally distributed plot
>> (which it is not). What are the x-axis and y-axis supposed to be?
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>
>
> This message has been checked for viruses but the contents of an
> attachment
> may still contain software viruses, which could damage your computer
> system:
> you are advised to perform your own checks. Email communications
> with the
> University of Nottingham may be monitored as permitted by UK
> legislation.
>
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list