Hello everyone,
I'd like to have suggestions about a common basic statistical approach, 
hope to be useful also for other R beginners.
 
When you first get some data (i.e length of river) you may want to look at its distribution.
Then you probably want to find which law follows this distribution, 
and to test the goodness of the fit.
 
For doing this simple analysis I am writing some code schematically represented below: 
1)calculate the histogram:
myhist<-hist(myData, breaks=....)
Question: how to calculate the standard deviation of each class of the hist? I have not seen it in the output of hist
2)Looking at the graph it seems to follow a linear model:
I plot the points: points(myhist$mids,myhist$counts)
Question: How to plot also the weights (vertical segments)?
3)I Calculate the linear equation using "lm" (in the case of linear model) knowing the weights computed in points 2)  
4)To test the goodness of the fit, a simply way is to use the reduced chi squared test which I haven't found on the base package. But it is simple to calculate like this
chisq.reduced<-(1/N)*sum((e-o)/w^2)
where e=expected values from fit
o=observed values
w=weights
5) Conclusion: If my chisq is lower than 1 I can conclude the model approximate well my data distribution.
 
Is it a good analysys of the problem?
Any answers to my questions or a better standard procedure (or package) where this work can be done easily, for the basic kind of distribution types?
Any kind of answer should be appreciated, including documentations or tutorial.
Thank you for reading till here!
Dr Copex



---------------------------------

	[[alternative HTML version deleted]]


