[R] Summary Statistics Help

bobo blezaic2 at gmail.com
Mon Apr 9 03:14:58 CEST 2012


Hi, I would really appreciate all the help I can get. Unfortunately, I am
really new to statistics! I hope you guys don't mind this. 

I am trying to find significance levels, beta, R, R squared, adjusted R
squared, standard error and t test.
FILE  http://r.789695.n4.nabble.com/file/n4541923/datpat.csv datpat.csv 

Variables (written exactly as in the Excel file) I am trying to examine are
:

a) Patents and FHouse 
b) Patents and FHouse controlled for extra, interstate, internationalized
c)Patents and FHouse controlled for internal threat (internal, DISAP, KILL,
TORT, POLPRIS, frac_eth, frac_rel)
d)Patents and EconGlob, SocGlob, PolGlob, Econflows,
e)Patents and GDP_Constant
f)Patents and durable, democ, autoc,

My code so far, I got stuck at section SUMMARY STATS:

datpat <- read.csv(file="datpat.csv", header=TRUE, rownames = FALSE)
datpat <- datpat[,-1]
datpat[,c(1:3,718)]
colnames(datpat)

# -------------------
# PRELIMINARY ANALYSES
# --------------------

# Overall
summary(datpat$Patents)

# By Nation (using the Index No.)

sumbynation <- by(datpat$Patents, datpat$Nation, summary)
mode(sumbynation)
sumbynation <-
data.frame(cbind(levels(datpat[,3]),t(matrix(unlist(sumbynation),6,
length(unique(datpat[,1]))))))
dim(sumbynation)

# Adding column names
colnames(sumbynation) <- c("ID", "Min", "1st Qu", "Median", "Mean", "3rd
Qu", "Max")

# Export table to LaTex

install.packages("xtable")
library(xtable)
?xtable

xtable(sumbynation)

# By Year (using the second column Year variable)

sumbyyear <- by(datpat$Patents, datpat$Year, summary)
sumbyyear <- cbind(unique(datpat[,2]),t(matrix(unlist(sumbyyear),6,
length(unique(datpat[,2])))))

# Adding column names
colnames(sumbyyear) <- c("ID", "Min", "1st Qu", "Median", "Mean", "3rd Qu",
"Max")

# Export table to LaTex
xtable(sumbyyear)

# --------------------------------
# New Analyses: Patents and FHouse 
# --------------------------------

# Global correlation of Pattens with FHouse values 
cor(datpat$Patents, datpat$FHouse)

# Conditional frequency count of data/time points by nation
by(datpat$Patents, datpat$Nation, length)

# Conditional correlations by nation
corbynation <- by(cbind(Patents = datpat$Patents, FHouse = datpat$FHouse),
datpat$Nation, cor)
length(corbynation)

natcor <- c()
for(i in 1:length(corbynation)){
	natcor <- c(natcor,unlist(corbynation[i])[2])
}

par(mar=c(4.5,4.5,5.5,1))
plot(natcor, type="p", pch=20, cex=2, axes=FALSE,
	main="Correlation of Patents and Freedom House Index by Nation",
	xlab="Nation", ylab="Correlation")
box()
axis(2)
axis(1, at=c(1:46), labels=c(levels(datpat[,3])))
abline(h=0.00, lty=2, col="red3")

# Global Patents by Freedom House Index
plot(datpat$Patents, datpat$FHouse)

---------------------------
# SUMMARY STATS
---------------------------
mod.1<-lm(Patents~FHouse, file="datpat.csv", header=TRUE)
summary(mod.1)
xtable(mod.1)


--
View this message in context: http://r.789695.n4.nabble.com/Summary-Statistics-Help-tp4541923p4541923.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list