**Need help with the following assignment have attached the required data and materials of the professor’s lecture. It needs to be performed in RStudio. All of the 10 answers of the questions need to be accurate.**

All of the detailed instructions and necessary documents are attached.

**Instructions and Assignment:**

**Advanced Analytics in R**

Attached Files:

IT836 Advanced R Assignment.pdf (98.987 KB) nbtrain.csv (306.612 KB)

In this assignment you will train a Naïve Bayes classifier on categorical data and predict individuals’ incomes. Import the nbtrain.csv file. Use the first 9010 records as training data and the remaining 1000 records as testing data.

In this assignment you will train a Naïve Bayes classifier on categorical data and predict individuals’ incomes. Import the nbtrain.csv file. Use the first 9010 records as training data and the remaining 1000 records as testing data. 1. Read the nbtrain.csv file into the R environment. 2. Construct the Naïve Bayes classifier from the training data, according to the formula “income ~ age + sex + educ”. To do this, use the “naiveBayes” function from the “e1071” package. Provide the model’s a priori and conditional probabilities. 3. Score the model with the testing data and create the model’s confusion matrix. Also, calculate the overall, 10-50K, 50-80K, and GT 80K misclassification rates. Explain the variation in the model’s predictive power across income classes. 4. Use the first 9010 records as training data and the remaining 1000 records as testing data. 5. What is propose of separating the data into a training set and testing set? 6. Construct the classifier according to the formula “sex ~ age + educ + income”, and calculate the overall, female, and male misclassification rates. Explain the misclassification rates? 7. Divide the training data into two partitions, according to sex, and randomly select 3500 records from each partition. Reconstruct the model from part (a) from these 7000 records. Provide the model’s a priori and conditional probabilities. 8. How well does the model classify the testing data? Explain why. 9. Repeat step (b) 4 several times. What effect does the random selection of records have on the model’s performance? 10. What conclusions can one draw from this exercise?

#section5.5.1TheGroceriesDataset#section5.5.1TheGroceriesDataset

data(Groceries)Groceriessummary(Groceries)class(Groceries)

# display the first 20 grocery labelsGroceries@itemInfo[1:20,]

# display the 10th to 20th transactionsapply(Groceries@data[,10:20], 2, function(r) paste(Groceries@itemInfo[r,”labels”], collapse=”, “))

#section5.5.2FrequentItemsetGe≠ration#section5.5.2FrequentItemsetGe≠ration

# frequent 1-itemsetsitemsets <- apriori(Groceries, parameter=list(minlen=1, maxlen=1, support=0.02, target=”frequent itemsets”))summary(itemsets)inspect(head(sort(itemsets, by = “support”), 10))

# frequent 2-itemsetsitemsets <- apriori(Groceries, parameter=list(minlen=2, maxlen=2, support=0.02, target=”frequent itemsets”))summary(itemsets)inspect(head(sort(itemsets, by =”support”),10))

# frequent 3-itemsetsitemsets <- apriori(Groceries, parameter=list(minlen=3, maxlen=3, support=0.02, target=”frequent itemsets”))inspect(sort(itemsets, by =”support”))

# frequent 4-itemsetsitemsets <- apriori(Groceries, parameter=list(minlen=4, maxlen=4, support=0.02, target=”frequent itemsets”))inspect(sort(itemsets, by =”support”))

# run Apriori without setting the maxlen parameteritemsets <- apriori(Groceries, parameter=list(minlen=1, support=0.02, target=”frequent itemsets”))

#section5.5.3Re–Ge≠rationandVisualization#section5.5.3Re̲Ge≠rationandVisualization

rules <- apriori(Groceries, parameter=list(support=0.001, confidence=0.6, target = “rules”))summary(rules)

plot(rules)plot(rules@quality)

# displays rules with top lift scoresinspect(head(sort(rules, by=”lift”), 10))

confidentRules <- rules[quality(rules)$confidence > 0.9]confidentRules

plot(confidentRules, method=”matrix”, measure=c(“lift”, “confidence”), control=list(reorder=TRUE))

# select the 5 rules with the highest lifthighLiftRules <- head(sort(rules, by=”lift”), 5)

plot(highLiftRules, method=”graph”, control=list(type=”items”))

This code covers the code presented in # Section 8.2 ARIMA Model###

section 8.2.5 Building and Evaluating an ARIMA Model###

install.packages(“forecast”) # install, if necessarylibrary(forecast)

# read in gasoline production time series# monthly gas production expressed in millions of barrelsgas_prod_input <- as.data.frame( read.csv(“c:/data/gas_prod.csv”) )

# create a time series objectgas_prod <- ts(gas_prod_input[,2])

#examine the time seriesplot(gas_prod, xlab = “Time (months)”, ylab = “Gasoline production (millions of barrels)”)

# check for conditions of a stationary time seriesplot(diff(gas_prod))abline(a=0, b=0)

# examine ACF and PACF of differenced seriesacf(diff(gas_prod), xaxp = c(0, 48, 4), lag.max=48, main=””)pacf(diff(gas_prod), xaxp = c(0, 48, 4), lag.max=48, main=””)

# fit a (0,1,0)x(1,0,0)12 ARIMA modelarima_1 <- arima (gas_prod, order=c(0,1,0), seasonal = list(order=c(1,0,0),period=12))arima_1

# it may be necessary to calculate AICc and BIC # http://stats.stackexchange.com/questions/76761/extract-bic-and-aicc-from-arima-objectAIC(arima_1,k = log(length(gas_prod))) #BIC

# examine ACF and PACF of the (0,1,0)x(1,0,0)12 residualsacf(arima_1$residuals, xaxp = c(0, 48, 4), lag.max=48, main=””)pacf(arima_1$residuals, xaxp = c(0, 48, 4), lag.max=48, main=””)

# fit a (0,1,1)x(1,0,0)12 ARIMA modelarima_2 <- arima (gas_prod, order=c(0,1,1), seasonal = list(order=c(1,0,0),period=12))arima_2

# it may be necessary to calculate AICc and BIC # http://stats.stackexchange.com/questions/76761/extract-bic-and-aicc-from-arima-objectAIC(arima_2,k = log(length(gas_prod))) #BIC

# examine ACF and PACF of the (0,1,1)x(1,0,0)12 residualsacf(arima_2$residuals, xaxp = c(0, 48, 4), lag.max=48, main=””)pacf(arima_2$residuals, xaxp = c(0, 48,4), lag.max=48, main=””)

# Normality and Constant Variance

plot(arima_2$residuals, ylab = “Residuals”)abline(a=0, b=0)

hist(arima_2$residuals, xlab=”Residuals”, xlim=c(-20,20))

qqnorm(arima_2$residuals, main=””)qqline(arima_2$residuals)

# Forecasting

#predict the next 12 monthsarima_2.predict <- predict(arima_2,n.ahead=12)matrix(c(arima_2.predict$pred-1.96*arima_2.predict$se, arima_2.predict$pred, arima_2.predict$pred+1.96*arima_2.predict$se), 12,3, dimnames=list( c(241:252) ,c(“LB”,”Pred”,”UB”)) )

plot(gas_prod, xlim=c(145,252), xlab = “Time (months)”, ylab = “Gasoline production (millions of barrels)”, ylim=c(360,440))lines(arima_2.predict$pred)lines(arima_2.predict$pred+1.96*arima_2.predict$se, col=4, lty=2)lines(arima_2.predict$pred-1.96*arima_2.predict$se, col=4, lty=2)

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.