Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I am trying to fit the log-log plot of the cumulative distribution of a network to one of three models: Exponential (EXP) ($P(k)\sim e^{-ak}$), Exponentially truncated power law (TRU) ($P(k)\sim k^{a-1}e^{k/k_c}$), and Power law (POWER) ($P(k)\sim k^{-a}$). I know this is a low-information test, but I am simply trying to determine which of the three models is the best fit (or possibly the least terrible fit!)

I realize that TRU has 2 degrees of freedom, while EXP and POWER have only 1 degree of freedom.

I have the following data in R:

logCPK<-c(0, -0.0014, -0.0038, -0.0056, -0.007, -0.013, -0.0165, -0.0222,     
-0.0261, -0.0354, -0.0478, -0.0581, -0.0714, -0.0846, -0.1068, -0.1205, 
-0.1403, -0.1638, -0.1837, -0.2091, -0.2265, -0.2517, -0.2766, -0.3121, 
-0.3381, -0.3744, -0.4079, -0.4485, -0.4869, -0.5326, -0.5881, -0.6383, 
-0.6959, -0.7586, -0.8199, -0.8853, -0.9624, -1.0352, -1.1341, -1.2294, 
-1.3521, -1.4982, -1.6824, -1.892, -2.182)

dataPOW<-c(0.3387, 0.2175, 0.1197, 0.0441, -0.0198, -0.0777, -0.1262, 
-0.1717, -0.2108, -0.2482, -0.281, -0.3113, -0.341, -0.3673, -0.3921, 
-0.4167, -0.4387, -0.4607, -0.4806, -0.4996, -0.5187, -0.536, -0.5535, 
-0.5695, -0.5856, -0.6004, -0.6154, -0.6292, -0.6426, -0.6561, -0.6686, 
-0.6808, -0.6932, -0.7046, -0.7158, -0.7272, -0.7383, -0.7486, -0.7586, 
-0.7689, -0.7785, -0.7883, -0.7974, -0.8064, -0.8155)

dataEXP<-c(0.1981, 0.168, 0.1364, 0.1063, 0.0762, 0.0445, 0.0144, -0.0172, 
-0.0473, -0.0789, -0.109, -0.1391, -0.1707, -0.2008, -0.2309, -0.2625, 
-0.2926, -0.3243, -0.3544, -0.3845, -0.4161, -0.4462, -0.4778, -0.5079, 
-0.5395, -0.5696, -0.6012, -0.6313, -0.6614, -0.6931, -0.7232, -0.7533, 
-0.7849, -0.815, -0.8451, -0.8767, -0.9083, -0.9384, -0.9685, -1.0001, 
-1.0302, -1.0619, -1.092, -1.1221, -1.1537)

dataTRU<-c(-0.1867, -0.0857, -0.0193, 0.0204, 0.0443, 0.057, 0.0602, 
0.0562, 0.0467, 0.0319, 0.0139, -0.0073, -0.0327, -0.0592, -0.088, -0.1202, 
-0.1525, -0.1881, -0.2234, -0.26, -0.2995, -0.3383, -0.38, -0.4205, -0.464, 
-0.5062, -0.5512, -0.5947, -0.6388, -0.6858, -0.731, -0.7767, -0.8253, 
-0.8719, -0.919, -0.9689, -1.0191, -1.0674, -1.116, -1.1673, -1.2165, 
-1.2685, -1.3183, -1.3684, -1.4212)

So my question is, how can I get the AIC values for the three models?

I have read, but not fully understand, the documentation for AIC(), which has a general syntax of: AIC(object, ..., k = 2).

Not understanding what I am doing, I have tried commands in R, like:

> AIC(logCPK~dataPOW)
Error in UseMethod("logLik") : 
  no applicable method for 'logLik' applied to an object of class "formula"

How can I calculate the AIC with the above data?

share|improve this question

1 Answer 1

The AIC function need an 'lm' or 'glm' object (linear models). See functions lm and glm

So just do : AIC(lm(logCPK~dataPOW))

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.