Linear model: Least-Squares Fit
This commit is contained in:
parent
952c77d802
commit
f02246966c
@ -2,3 +2,27 @@
|
||||
# Degree Distribution
|
||||
# Professor: Dr. McKinney, Spring 2022
|
||||
# Noah Schrick - 1492657
|
||||
|
||||
library(igraph)
|
||||
library(igraphdata)
|
||||
data(yeast)
|
||||
g <- yeast
|
||||
|
||||
################# Linear model: Least-Squares Fit #################
|
||||
g.hist <- hist(degree(g), freq=FALSE)
|
||||
g.seq <- 0:max(degree(g)) # x-axis
|
||||
g.breaks <- g.hist$breaks[-c(1,2)] # remove 0 and low degrees
|
||||
g.probs <- g.hist$density[-1] # make lengths match
|
||||
|
||||
# Need to clean up probabilities that are 0
|
||||
nz.probs.mask <- g.probs!=0
|
||||
g.breaks.clean <- g.breaks[nz.probs.mask]
|
||||
g.probs.clean <- g.breaks[nz.probs.mask]
|
||||
|
||||
plot(log(g.breaks.clean), log(g.probs.clean))
|
||||
g.fit <- lm(log(g.probs.clean)~log(g.breaks.clean))
|
||||
summary(g.fit)
|
||||
coef(g.fit)[2]
|
||||
|
||||
|
||||
################# Max-Log-Likelihood #################
|
||||
Loading…
x
Reference in New Issue
Block a user