slopebypoint | R Documentation |
Returns the slope from linear regression with x values as equally spaced 1:length
slopebypoint(data)
data |
Returns the slope from linear regression with x values as equally spaced 1:length |
Returns the slope (i.e. localised tangent) from linear regression with x values as equally spaced 1:length. The usefulness of this function is to reduce a time series type of data collected at equal time intervals.
N=number of data points over which to calculate the slope.
An object of type numeric.
Glenn J. Tattersall
lm
## Define a vector of 50 random numbers from 1 to 100
y<-ceiling(runif(50, 0, 100))
# Calculate the slope with respect to the index values (i.e. 1 to 50)
# instead of an x axis, this will provide a slope value of y vs. index
s<-slopebypoint(y)
s
# same as if typing:
lm(y~seq(0,length(y)-1,1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.