ECON30025/ECOM90020 Assignment 1, 2025

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


ECON30025/ECOM90020

Assignment 1, 2025

Due 11:59 pm Sunday, April 13, 2025

For those in ECON30025, this assignment is worth 20% of your final grade. Please answer all of the questions I, II and III for a possible total of 40 points (each point  is 1/2% of final grade).  The word limit on this assignment is 1,000 words (approximately 5 pages). Note that computer code not part of the answer should be included in an appendix.

For those in ECOM90020, this assignment is worth 25% of your final grade. Please answer questions I, II and III, and IV for a possible total of 50 points (each point is 1/2% of the final grade).  The word limit on this assignment is 1,500 words (approximately 8 pages).  Note that computer code that is not part of the answer should be put in an appendix.

Make sure to include the coversheet with your answers. Read the instructions on the cover sheet. Try to keep your answers short and clear. Please submit copies of all the programs. Write not more than 5/8 pages of text (not including the programs) and cut and paste any results into a Word document. The program code should be included as an appendix. When writing code remember to add comments to the programs so they would look like ones that you would write for someone else to use. One method for saving space is to first paste the results as text then cut it and re-paste the code and results as a  picture (with Paste Special). This will allow you to resize these parts of your answer so that they take less space.  All assignments are to be submitted as PDFs using the assignment tool in LMS.

It is not enough just to provide the computer results - you will be graded on your interpretation of what you find.  If you are in doubt as to a particular definition or question - state your assumption and move on.

Part I. (20ptsReformatting code.

Consider the code listed below (q1_question_25.sas):

%let fileloc=C:\ECON30025_2025\data;proc import

datafile="&fileloc\un_plus .csv" out=un_plus replace dbms=csv;run;data

un_plus;set un_plus;productivity=productivity/1000;run;proc corr data=un_plus nomiss cov;var  EQ_MATH INTERNET ARTICLES R_N_D WOMEN_MPS;run;proc iml;reset fuzz=1e-10;use un_plus(where=(nmiss(EQ_MATH, INTERNET, ARTICLES, R_N_D,

WOMEN_MPS)=0));read all var{EQ_MATH INTERNET ARTICLES R_N_D WOMEN_MPS} into

YY [rowname=country];n=ncol(YY);obs=nrow(YY);cr=standard(YY)`*standard(YY)

/(obs-1);cov=(YY-j(obs,1,1)*YY[:,])`*(YY-j(obs,1,1)*YY[:,])/(obs-1);print

"??=" cr, " ??=" cov;call eigen(e_values, e_vec, cr);print "??=" e_values, " ??=" e_vec;VarExp=cusum(e_values)/sum(e_values);print "??"

varexp;chk=j(n,n,0);do ii=1 to n;do jj=1 to n;chk[ii,jj]=(e_vec[,jj]`

*e_vec[,ii]);end;end;print "??=" chk;estimate=e_vec*diag(e_values)*e_vec`; diff=cr-estimate;print "??=" estimate,"??=" cr,"??=" diff;est=j(n,n,0);do ii=1 to n;est=est+e_values[ii,]#e_vec[,ii]*e_vec[,ii]`;end;print "??="

est;print "??" (e_values`);pc=(standard(YY))*e_Vec;cor_pc=corr(pc);print "??" cor_pc;pc_names='prin1':'prin5';create pcsYY from pc[colname=pc_names

];append from pc;create namesYY from country[colname="country"];append from country;quit;

I-1.  The purpose of this exercise is to demonstrate that you can write readable code.  Rewrite this code to perform the same analysis so that one can follow what is done in this program in a similar fashion to the code that appears in the subject notes.

I-1a(5pts) Add blank lines and comment lines to describe each procedure and data step. Replace the ?? with the appropriate identification of the results.

I-1b(3pts) Provide tabs to define margins for each line of code.

I-1c(3pts) Space out equations and definitions so that operators have space before and after.

I-1d(3pts) Provide titles for each section of the results that are printed.

I-1e(3pts) Identify what each line of the Proc IML code performs with a comment.

I-2.  (3 pts) Modify this code to read the unplus data into SAS and print the results.

Part II. (10 ptsLinear Equation Solving

Consider a system of linear equations defined as:

2x1 + 2x2  + 3x3  + 3x4  = 9 − x3

10 − 2x1 + 4x2  =  − 3x4

x3 +  5x4  = 2x2  − 4x3

6x4  − 7 = 4x3  − 5x1

II-1.(3 pts) Define the matrix A, and the vectors b and x where this system of equations is equivalent to the expression: Ax = b .  Then modify the IML routine iml_example1 to solve for the elements of x.

II-2.(3 pts) We find another set of four equations defined as:

2x3 + 12x4  = 3x2  − 9

10x4  + 5 = x2  +10

5x1 + 18x3  =  − 7x4  − 3

3x1 + 2x2  = x4  − 6 − 8x3

How does the solution of this set of equations differ from the solution you found from the first set in part 1?

II-3.(2pts) Describe how one might find a solution for the vector x that uses all the information in the 8 equations defined in parts 1 and 2. (Hint: We might consider a method used in regression).

II-4.(2 pts) How does the answer in part 3 differ from the average of the results you found in parts 1 and 2?

Part III. (10pts) Scraping for data.

One method for collecting data is to use information from the internet that was not originally in data format such as a downloadable spreadsheet. Alternatively, one can cut and paste a table from the site to an Excel spreadsheet and convert it to a table for use in a program such as SAS.

However, when the data is not on one page or multiple pages, there could be other information on the page that we need to remove. One option is to automate the process. Note that there is always a trade-off between the time spent writing a routine to read the websites or to record the data manually. The main advantage of writing a routine to read the data, which is sometimes referred to as scraping, is that one can repeatedly return to the same website for updates to the information. Also, if the website stays the same, this allows the replication of the analysis with this data.

The routine below scrapes car specifications data from the website https://www.carsguide.com.au/ which contains data for used automobiles for sale in Australia. It is typical of the programs to read the code that generates the webpage written in HyperText Markup Language (HTML).  In this case, we read the code and search it for the information we want to summarize. To do this, I have written the program Carsguide.sas, which is listed below:

This program is an example of the methods used for this.  It involves searching the code corresponding to a page you can see for the information you want.  This data provides the range of the prices for cars of this make and model.

This program employs several SAS features with which you will need to become familiar.  If there are parts that you do not recognise, I suggest that you use the help documents in SAS to familiarise yourself with the elements of the program you need to check out.

•   It uses a macro to perform multiple steps with one command.

•   The macro constructs a series of data sets to read the website code to search for key phases and words that indicate the location of the information required.

•   It finishes by concatenation of data sets so that one can compare data from across suburbs.

III-1.(4pts) For the Volvo S60 check the code that is identified as the portion of the website that lists the sales information by printing out the lines of the code the program collects in the dataset that records just the sales information as recorded in the SAS data set work.first. Describe where the data on the year, and the prices can be located. (do not list all the data in your answer the lines of code for one of the sales.)  Note that each line of the website code has been provided with a number by the routine (the value of num).

III-2.(6pts total) Select at least 7 and not more than 10 cars from Table III-1 by using a series of macro calls for each as in the example and perform the following.  You do not need to use this list it may be more interesting to collect data for different types of cars for example, prestige versus common cars or sports cars versus family cars.  You can go to the website to find other cars, but there may not be much data for many models.  Some models have only a few years of data and there is no indication as to how many sales or options on the car were used for the price calculation.  Make sure to connect multiple word names with a - as used in the names listed in Table III-1.  (Note that this routine will generate many lines of results in the log file, and you may need to drop these lines if SAS stops here.)  It may be necessary to save the results to a file.

To save a SAS data set to an Excel spreadsheet file you can use the code in the program as shown below:

%LET LOC = C:\data;

libname xlXLSX "&loc\cars .xlsx" ; data xl1 .total1 ; set total ;

run;

This code will write a sas data set called total to an Excel file called c:\data\cars.xlsx to a sheet in that file called total1.  Note that when you do this, you must not open this spreadsheet while you are trying to write to it.  You can look at it but remember to close it before you either write to it again or read it.

You can reverse the process to read the file an Excel spreadsheet into SAS using the code as:

%LET LOC = C:\data;

libname xlXLSX "&loc\cars .xlsx" ; data total ; set xl1 .total1 ;

run;

Note that the SAS formats and labels will be lost when doing this.

III-2a (3pts) Using the car data that you scrape, find which car makes and models that retain the highest value and those that lose the most.  Is there any relationship between the original price and the loss in value?  Do you see variation in the loss of value over time?  (Note that in some cases some models increase in value as denoted by negative depreciation).

III-2b (3ptsUsing proc sgplot plot the relationship between the original price and the % depreciation.  Provide an interpretation of the plot.  Make sure to identify which make and model are plotted.



发表评论

电子邮件地址不会被公开。 必填项已用*标注