[R] Is Least Squares the Best Approach?
Jason Rupert
jasonkrupert at yahoo.com
Tue Feb 2 04:56:51 CET 2010
Assuming I have two data sets that are two dimensional that should from similar functions, is Least Squares or a related approach the best way to compare these 2-D data sets? I guess I would like to know how related the two data sets are and if they are from the same function or close to being from the same function.
Thanks for any tips on this topic, as when I look at least squares I only see how well a function fits a set of data and then when I look at chi squared it looks like it is only discussing 1-D type data. Any insights are appreciated, as I believe I am overlooking something.
num_vals<-1000
from_val<-0
to_val<-360
input_degree_one<-seq(from = from_val, to = to_val, length.out = num_vals)
input_degree_one<-runif(num_vals,
min=from_val,
max=to_val)
input_degree_two<-runif(num_vals,
min=from_val,
max=to_val)
input_radian_one<-sort(input_degree_one)*2*pi/180
input_radian_two<-sort(input_degree_two)*2*pi/180
omega_one<-0.0
output_one<-sin(input_radian_one+omega_one)
omega_two<-3.0*2*pi/180
output_two<-sin(input_radian_two+omega_two)
plot(0, 0,
ylim=c(-1, 1),
xlim=c(0, 360),
col=0.0,
xlab=c("Input"),
ylab=c("Output"))
points(input_degree, output_one, col="blue")
points(input_degree, output_two, col="red")
More information about the R-help
mailing list