From f02246966cce0b8a25eea61a62b9024e95d6b4ef Mon Sep 17 00:00:00 2001 From: noah Date: Mon, 11 Apr 2022 13:37:21 -0500 Subject: [PATCH] Linear model: Least-Squares Fit --- Schrick-Noah_CS-7863_Homework-4.R | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Schrick-Noah_CS-7863_Homework-4.R b/Schrick-Noah_CS-7863_Homework-4.R index 5828aa4..aa994d0 100644 --- a/Schrick-Noah_CS-7863_Homework-4.R +++ b/Schrick-Noah_CS-7863_Homework-4.R @@ -1,4 +1,28 @@ # Homework 4 for the University of Tulsa' s CS-7863 Network Theory Course # Degree Distribution # Professor: Dr. McKinney, Spring 2022 -# Noah Schrick - 1492657 \ No newline at end of file +# 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 ################# \ No newline at end of file