100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary Quantitative Innovation Analytics - R Formulas & knowledge clips $7.59
Add to cart

Summary

Summary Quantitative Innovation Analytics - R Formulas & knowledge clips

 4 views  0 purchase
  • Course
  • Institution

In this document, all different formulas used for the program R during this course are provided. Furthermore, I added the important parts of the knowledge clips with supporting images to make it easier to understand.

Preview 4 out of 73  pages

  • December 21, 2024
  • 73
  • 2023/2024
  • Summary
avatar-seller
General
● install packages
install.packages(“ …”)
library(...)


● Checking class of variable
class()


● Changing class of variables
character_var <- as.character(numeric_var)
→ a character type variable is one that stores textual data, such as letters, words, or
any other character strings
numeric_var <- as.numeric(character_var)
Numeric variables are used to represent quantitative, continuous, or discrete
numeric values, such as integers or real numbers.
date_var <- as.Date("2022-01-01")
→ pick a date
factor_variable <- as.factor(char_vector)
→ represent categorical data in R

● checking NAs
is.na(df)
any(is.na(x)))

● removing NAs
unique()
na.omit()
cleaned_vec <- vec[complete.cases(vec)]


● providing output
summary()


● merging datasets
package = dplyr
inner_join()
result <- inner_join(df1, df2, by = "ID")
left_join() or right_join()
merge()

● interpretation R-squared (R2)

,If R-squared is close to 1, it suggests that the model is a good fit, and a large
proportion of the variability in the dependent variable is explained by the independent
variables.
If R-squared is close to 0, it indicates that the model does not provide a good fit to
the data, and the independent variables do not explain much of the variability in the
dependent variable.

● interpretation intercepts/coefficients
The sign of the coefficient (positive or negative) indicates the direction of the effect.
If the coefficient is positive (e.g., +29.4), it suggests that an increase in the
independent variable is associated with an increase in the dependent variable. If it is
negative, the interpretation is the opposite.

● select and filter data
package = dplyr
selected_data <- select(data, ID, Name)
filtered_data <- filter(data, Age > 25, Score >= 90)
== → selecting on date for example

!= → not want to include this particular thing


● Family

,Model 1: Ordinary Least Squares Models
● Load dataset
airports <- read.delim(file.choose(), sep=",", header=F)
routes <- read.delim(file.choose(), sep=",", header=F)
airunuts <- read.delim(file.choose(), sep=",", header=T)


● Changing names of columns
names(airports) <- c("id", "name", "city", "country", "iata", "guko", "lat", "lon",
"altitude", "timezone", "dst", "timezonename", "type", "source")
names(airports)
names(routes) <- c("Airline", "AirlineID", "SourceAirport", "SourceairportID",
"Destairport", "DestairportID", "Codeshare", "Stops", "Equipment")
names(routes) <-tolower(names(routes))


● Package edges&nodes
library(igraph)


● Making graph from edgelist
edgelist <- routes[c("sourceairport", "destairport")]
package = igraph
route1 <- graph_from_data_frame(edgelist,directed = T,vertices = NULL)


● Calculating mean & median
mean(degree(route1,mode = "in"))
median(degree(route1,mode = "in"))


● Calculating standard deviation of indegree
sd(degree(route1,mode = "in"))


● Calculating indegree and sorting it
sort(degree(route1, mode = "in"), decreasing= T)[1:12]


● Making histogram
hist(degree(route1), col="navyblue", breaks = 50 )


● Create edgelist with large airports only >411 degrees (top 12)
sa <- data.frame(table(edgelist$sourceairport))

, ds <- data.frame(table(edgelist$destairport))
edgelist2 <- merge(edgelist, sa, by.x = "sourceairport", by.y = "Var1", all = T )
edgelist2 <- merge(edgelist2, ds, by.x = "destairport", by.y = "Var1", all = T )
edgelist3 <- edgelist2[edgelist2$Freq.x >411 & edgelist2$Freq.y >411,]
route2 <- graph_from_data_frame(edgelist3[1:2])
plot(route2)


● Differences transitivity, betweenness & closeness
Transitivity: If two neighboring airports are unconnected, people have a larger
likelihood to pass your airport. They might also take an alternative equally long
route however.
Betweenness: Expresses how many people are forced to go through your airport
if they want to take the shortest route.
Closeness: Says something about how many steps you are from other airports.
This makes you are more attractive airport.


● Making histograms of centrality measures
hist(transitivity(route1, type ="local", isolates = "zero"), col="coral", breaks = 50)
hist(betweenness(route1, directed = T), col = "darkorchid2", breaks = 50)
hist(closeness(route1, normalized=F,mode = "in" ), col = "deepskyblue", breaks =
50)
round(sort(betweenness(route1, directed = T), decreasing =T)[1:12],0)
round(sort((closeness(route1, mode="in" )), decreasing =T)[1:12],2)


● run a linear model
model0 <- lm(y ~x, data= namedataset, na.action = na.exclude)

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Kim2001. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.59. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

48298 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 15 years now

Start selling
$7.59
  • (0)
Add to cart
Added